@@ -548,28 +548,31 @@ proc installNimbusApiHandlers*(router: var RestRouter, node: BeaconNode) =
548
548
node.withStateForBlockSlotId(bslot):
549
549
return withState(state):
550
550
when consensusFork >= ConsensusFork.Capella:
551
- let summariesFork = historicalSummariesForkAtConsensusFork(consensusFork).valueOr:
552
- return RestApiResponse.jsonError(Http404, HistoricalSummariesUnavailable)
553
-
554
- withHistoricalSummariesFork(summariesFork):
555
- let response = getHistoricalSummariesResponse(historicalSummariesFork)(
556
- historical_summaries: forkyState.data.historical_summaries,
557
- proof: forkyState.data.build_proof(
558
- historicalSummariesFork.historical_summaries_gindex).expect(" Valid gindex" ),
559
- slot: bslot.slot)
560
-
561
- if contentType == jsonMediaType:
562
- RestApiResponse.jsonResponseFinalizedWVersion(
563
- response,
564
- node.getStateOptimistic(state),
565
- node.dag.isFinalized(bslot.bid),
566
- consensusFork)
567
- elif contentType == sszMediaType:
568
- let headers = [(" eth-consensus-version" , consensusFork.toString())]
569
- RestApiResponse.sszResponse(response, headers)
570
- else :
571
- RestApiResponse.jsonError(Http500, InvalidAcceptError)
551
+ const historicalSummariesFork = historicalSummariesForkAtConsensusFork(
552
+ consensusFork
553
+ )
554
+ .expect(" HistoricalSummariesFork for Capella onwards" )
555
+
556
+ let response = getHistoricalSummariesResponse(historicalSummariesFork)(
557
+ historical_summaries: forkyState.data.historical_summaries,
558
+ proof: forkyState.data
559
+ .build_proof(historicalSummariesFork.historical_summaries_gindex)
560
+ .expect(" Valid gindex" ),
561
+ slot: bslot.slot,
562
+ )
572
563
564
+ if contentType == jsonMediaType:
565
+ RestApiResponse.jsonResponseFinalizedWVersion(
566
+ response,
567
+ node.getStateOptimistic(state),
568
+ node.dag.isFinalized(bslot.bid),
569
+ consensusFork,
570
+ )
571
+ elif contentType == sszMediaType:
572
+ let headers = [(" eth-consensus-version" , consensusFork.toString())]
573
+ RestApiResponse.sszResponse(response, headers)
574
+ else :
575
+ RestApiResponse.jsonError(Http500, InvalidAcceptError)
573
576
else :
574
577
RestApiResponse.jsonError(Http404, HistoricalSummariesUnavailable)
575
578
0 commit comments