INNER CODE UNIT · TypeScript

priority

blueshift-gg/doppler · packages/core/index.ts:141

  const priority = (BigInt(unitPrice) * BigInt(requestedComputeUnits) + 999_999n) / 1_000_000n;
  return {
    computeUnits,
    loadedBytes,
    requestedComputeUnits,
    requestedLoadedBytes: loadedBytes + 2 * ACCOUNT_OVERHEAD + COMPUTE_BUDGET_PROGRAM_LEN,
    lamports: BigInt(signatures) * LAMPORTS_PER_SIGNATURE + priority,
  };
}

function layout(fields: unknown): { slots: Slot[]; size: number } {
  if (!Array.isArray(fields) || fields.length === 0) throw new TypeError('a payload needs at least one field');
  const slots: Slot[] = [];
  let size = 0;
  for (const field of fields as FieldLike[]) {
    const { name, type, len = 1 } = field;
    if (typeof name !== 'string' || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new TypeError('a field name must be an identifier');
    if (slots.some((s) => s.name === name)) throw new TypeError(`${name}: a field name must be unique`);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…