Skip to content

Commit

Permalink
wire in the syncstate callback to rpc (#3049)
Browse files Browse the repository at this point in the history
  • Loading branch information
advaita-saha authored Feb 6, 2025
1 parent 2961905 commit 796c2f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nimbus/rpc/server_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,16 @@ proc setupServerAPI*(api: ServerAPIRef, server: RpcServer, ctx: EthContext) =

server.rpc("eth_syncing") do() -> SyncingStatus:
## Returns SyncObject or false when not syncing.
if api.com.syncState != Waiting:
let (start, current, target) = api.com.beaconSyncerProgress()
if start == 0 and current == 0 and target == 0:
return SyncingStatus(syncing: false)
else:
let sync = SyncObject(
startingBlock: Quantity(api.com.syncStart),
currentBlock: Quantity(api.com.syncCurrent),
highestBlock: Quantity(api.com.syncHighest),
startingBlock: Quantity(start),
currentBlock: Quantity(current),
highestBlock: Quantity(target),
)
return SyncingStatus(syncing: true, syncObject: sync)
else:
return SyncingStatus(syncing: false)

proc getLogsForBlock(
chain: ForkedChainRef, header: Header, opts: FilterOptions
Expand Down

0 comments on commit 796c2f7

Please sign in to comment.