Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/SyncStatus

primitives/SyncStatus

Type Aliases

SyncProgress

SyncProgress = object
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:7 Active sync progress information

Properties

currentBlock
readonly currentBlock: BlockNumberType
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:9
highestBlock
readonly highestBlock: BlockNumberType
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:10
knownStates?
readonly optional knownStates: Type
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:12
pulledStates?
readonly optional pulledStates: Type
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:11
startingBlock
readonly startingBlock: BlockNumberType
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:8

SyncStatusType

SyncStatusType = false | SyncProgress
Defined in: src/primitives/SyncStatus/SyncStatusType.ts:34 Sync status from eth_syncing false = not syncing (node is fully synced) object = actively syncing with progress information

Example

// Not syncing
const notSyncing: SyncStatusType = false;

// Actively syncing
const syncing: SyncStatusType = {
  startingBlock: 0n,
  currentBlock: 1000n,
  highestBlock: 2000n,
};

Variables

SyncStatus

const SyncStatus: object
Defined in: src/primitives/SyncStatus/index.ts:44

Type Declaration

from()
from: (value) => SyncStatusType = _from
Create SyncStatus from RPC response
Parameters
value
RPC sync status boolean | { currentBlock: string | number | bigint; highestBlock: string | number | bigint; knownStates?: string | number | bigint; pulledStates?: string | number | bigint; startingBlock: string | number | bigint; }
Returns
SyncStatusType SyncStatus
Example
const notSyncing = SyncStatus.from(false);
const syncing = SyncStatus.from({
  startingBlock: 0n,
  currentBlock: 1000n,
  highestBlock: 2000n,
});
getProgress()
getProgress: (status) => number
Parameters
status
true | SyncStatusType | { currentBlock: bigint; highestBlock: bigint; startingBlock: bigint; }
Returns
number
isSyncing()
isSyncing: (status) => boolean
Parameters
status
true | SyncStatusType | { currentBlock: bigint; highestBlock: bigint; startingBlock: bigint; }
Returns
boolean

Functions

_getProgress()

_getProgress(status): number
Defined in: src/primitives/SyncStatus/getProgress.js:14 Calculate sync progress as percentage

Parameters

status
SyncStatusType Sync status

Returns

number Progress percentage (0-100), or 100 if not syncing

Throws

If status is syncing but has invalid block numbers

Example

const progress = SyncStatus.getProgress(status);
console.log(`Syncing: ${progress.toFixed(2)}%`);

_isSyncing()

_isSyncing(status): boolean
Defined in: src/primitives/SyncStatus/isSyncing.js:16 Check if node is actively syncing

Parameters

status
SyncStatusType Sync status

Returns

boolean True if syncing

Example

if (SyncStatus.isSyncing(status)) {
  console.log("Node is syncing");
} else {
  console.log("Node is synced");
}

from()

from(value): SyncStatusType
Defined in: src/primitives/SyncStatus/from.js:17 Create SyncStatus from RPC response

Parameters

value
RPC sync status boolean | { currentBlock: string | number | bigint; highestBlock: string | number | bigint; knownStates?: string | number | bigint; pulledStates?: string | number | bigint; startingBlock: string | number | bigint; }

Returns

SyncStatusType SyncStatus

Example

const notSyncing = SyncStatus.from(false);
const syncing = SyncStatus.from({
  startingBlock: 0n,
  currentBlock: 1000n,
  highestBlock: 2000n,
});

getProgress()

getProgress(status): number
Defined in: src/primitives/SyncStatus/index.ts:27

Parameters

status
true | SyncStatusType | { currentBlock: bigint; highestBlock: bigint; startingBlock: bigint; }

Returns

number

isSyncing()

isSyncing(status): boolean
Defined in: src/primitives/SyncStatus/index.ts:14

Parameters

status
true | SyncStatusType | { currentBlock: bigint; highestBlock: bigint; startingBlock: bigint; }

Returns

boolean