SyncProgress Fields
startingBlock— Block when sync startedcurrentBlock— Current blockhighestBlock— Target blockpulledStates?— Downloaded state entriesknownStates?— Known state entries
Node sync status from eth_syncing
import { SyncStatus } from 'voltaire-effect'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'
const parse = Schema.decodeSync(SyncStatus.JSON)
// Synced
const synced = parse(false)
// Syncing
const syncing = parse({
startingBlock: 0n,
currentBlock: 1000n,
highestBlock: 2000n
})
// Effect constructor (accepts number | string | bigint)
const program = Effect.gen(function* () {
const status = yield* SyncStatus.from({
startingBlock: 0,
currentBlock: '1000',
highestBlock: 2000n
})
if (status === false) return 100
return Number(status.currentBlock * 100n / status.highestBlock)
})
startingBlock — Block when sync startedcurrentBlock — Current blockhighestBlock — Target blockpulledStates? — Downloaded state entriesknownStates? — Known state entriesconst result = await Effect.runPromiseExit(SyncStatus.from({ currentBlock: -1n }))
// result._tag === 'Failure' → SyncStatusError