Skip to content

Commit 1228582

Browse files
authored
Add Electra/Fulu support to ncli dumpBlock (#7017)
As the code for dumping blocks in `ncli` is not maintained, replace it with logic that automatically works with new forks. Similar semantics, except that `ConsensusFork` is now enumerated in backward direction.
1 parent 8d99002 commit 1228582

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

ncli/ncli_db.nim

+8-13
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,14 @@ proc cmdDumpBlock(conf: DbConf) =
450450
if shouldShutDown: quit QuitSuccess
451451
try:
452452
let root = Eth2Digest.fromHex(blockRoot)
453-
if (let blck = db.getBlock(
454-
root, phase0.TrustedSignedBeaconBlock); blck.isSome):
455-
dump("./", blck.get())
456-
elif (let blck = db.getBlock(
457-
root, altair.TrustedSignedBeaconBlock); blck.isSome):
458-
dump("./", blck.get())
459-
elif (let blck = db.getBlock(root, bellatrix.TrustedSignedBeaconBlock); blck.isSome):
460-
dump("./", blck.get())
461-
elif (let blck = db.getBlock(root, capella.TrustedSignedBeaconBlock); blck.isSome):
462-
dump("./", blck.get())
463-
elif (let blck = db.getBlock(root, deneb.TrustedSignedBeaconBlock); blck.isSome):
464-
dump("./", blck.get())
465-
else:
453+
var found = false
454+
withAll(ConsensusFork):
455+
if not found:
456+
let blck = db.getBlock(root, consensusFork.TrustedSignedBeaconBlock)
457+
if blck.isSome:
458+
found = true
459+
dump("./", blck.get())
460+
if not found:
466461
echo "Couldn't load ", blockRoot
467462
except CatchableError as e:
468463
echo "Couldn't load ", blockRoot, ": ", e.msg

0 commit comments

Comments
 (0)