Skip to content

Reference

waitForRoundChange

Poll validator mining-round snapshots until round_number exceeds initial baseline or timeout elapses.

Captures initialRoundNumber via getCurrentRoundNumber, then loops until Date.now() exceeds startTime + maxWaitTime (default 20 minutes). Each iteration waits 20 seconds between getOpenAndIssuingMiningRounds polls (prints '.' to stdout for observability).

Throws MINING_ROUND_NOT_FOUND timeout OperationError if round never increments.

Swallows intermittent exceptions inside polling loop (sleeps then retries).

Setup

import { Canton, waitForRoundChange } from '@fairmint/canton-node-sdk';

const canton = new Canton({
  network: 'NETWORK_NAME',
  partyId: 'PARTY_ID',
});

Minimal example

await waitForRoundChange(canton.validator, 15 * 60 * 1000);
console.log('Advanced');

Parameters

  • validatorClient — Implements MiningRoundClient.
  • maxWaitTime (optional number, ms) — Defaults 1200000 (20 minutes).

Returns

Promise<void> — Resolves silently once currentRoundNumber > initialRoundNumber.

Errors

Throws OperationError MINING_ROUND_NOT_FOUND with timeout diagnostics.

Caveats

Writes '.' characters to process.stdout during waits — noisy in CI logs.

Source

src/utils/mining/mining-rounds.ts