@@ -260,14 +260,17 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
260260 # https://ethereum.github.io/beacon-APIs/#/Node/getSyncingStatus
261261 router.api2 (MethodGet , " /eth/v1/node/syncing" ) do () -> RestApiResponse :
262262 let
263- wallSlot = node.currentSlot
264263 headSlot = node.dag.head.slot
265- distance = wallSlot - headSlot
264+ distance =
265+ if isNil (node.syncOverseer):
266+ 0 'u64
267+ else :
268+ node.syncOverseer.syncDistance ()
266269 isSyncing =
267- if isNil (node.syncManager ):
270+ if isNil (node.syncOverseer ):
268271 false
269272 else :
270- node.syncManager.inProgress
273+ node.syncOverseer. syncInProgress ()
271274 isOptimistic =
272275 if node.currentSlot ().epoch () >= node.dag.cfg.BELLATRIX_FORK_EPOCH :
273276 Opt .some (not node.dag.head.executionValid)
@@ -290,9 +293,13 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
290293 router.api2 (MethodGet , " /eth/v1/node/health" ) do () -> RestApiResponse :
291294 # TODO : Add ability to detect node's issues and return 503 error according
292295 # to specification.
296+ if isNil (node.syncOverseer):
297+ return RestApiResponse .response (Http200 )
298+
293299 let status =
294- if node.syncManager.inProgress :
300+ if node.syncOverseer. syncInProgress () :
295301 Http206
296302 else :
297303 Http200
304+
298305 RestApiResponse .response (status)
0 commit comments