use `forks` sugar in `nimbus_light_client` (#5653)
Reduce code duplication and maintenance burden by using `withAll` sugar.
This commit is contained in:
parent
91029ce6d6
commit
483e70d7a0
|
@ -150,31 +150,14 @@ programMain:
|
|||
|
||||
info "Listening to incoming network requests"
|
||||
network.initBeaconSync(cfg, forkDigests, genesisBlockRoot, getBeaconTime)
|
||||
network.addValidator(
|
||||
getBeaconBlocksTopic(forkDigests.phase0),
|
||||
proc (signedBlock: phase0.SignedBeaconBlock): ValidationResult =
|
||||
toValidationResult(
|
||||
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
|
||||
network.addValidator(
|
||||
getBeaconBlocksTopic(forkDigests.altair),
|
||||
proc (signedBlock: altair.SignedBeaconBlock): ValidationResult =
|
||||
toValidationResult(
|
||||
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
|
||||
network.addValidator(
|
||||
getBeaconBlocksTopic(forkDigests.bellatrix),
|
||||
proc (signedBlock: bellatrix.SignedBeaconBlock): ValidationResult =
|
||||
toValidationResult(
|
||||
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
|
||||
network.addValidator(
|
||||
getBeaconBlocksTopic(forkDigests.capella),
|
||||
proc (signedBlock: capella.SignedBeaconBlock): ValidationResult =
|
||||
toValidationResult(
|
||||
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
|
||||
network.addValidator(
|
||||
getBeaconBlocksTopic(forkDigests.deneb),
|
||||
proc (signedBlock: deneb.SignedBeaconBlock): ValidationResult =
|
||||
toValidationResult(
|
||||
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
|
||||
withAll(ConsensusFork):
|
||||
let forkDigest = forkDigests[].atConsensusFork(consensusFork)
|
||||
network.addValidator(
|
||||
getBeaconBlocksTopic(forkDigest), proc (
|
||||
signedBlock: consensusFork.SignedBeaconBlock
|
||||
): ValidationResult =
|
||||
toValidationResult(
|
||||
optimisticProcessor.processSignedBeaconBlock(signedBlock)))
|
||||
lightClient.installMessageValidators()
|
||||
waitFor network.startListening()
|
||||
waitFor network.start()
|
||||
|
|
Loading…
Reference in New Issue