use `ConsensusFork.init` for parsing lowercase version (#6015)
Instead of maintaining string to `ConsensusFork` version inline, use shared helper that also comes with static assertion checks for completion.
This commit is contained in:
parent
b4db011daf
commit
542854e743
|
@ -1413,18 +1413,8 @@ template prepareForkedBlockReading(blockType: typedesc,
|
||||||
reader.raiseUnexpectedField("Multiple version fields found",
|
reader.raiseUnexpectedField("Multiple version fields found",
|
||||||
blockType.name)
|
blockType.name)
|
||||||
let vres = reader.readValue(string).toLowerAscii()
|
let vres = reader.readValue(string).toLowerAscii()
|
||||||
case vres
|
version = ConsensusFork.init(vres)
|
||||||
of "phase0":
|
if version.isNone():
|
||||||
version = Opt.some(ConsensusFork.Phase0)
|
|
||||||
of "altair":
|
|
||||||
version = Opt.some(ConsensusFork.Altair)
|
|
||||||
of "bellatrix":
|
|
||||||
version = Opt.some(ConsensusFork.Bellatrix)
|
|
||||||
of "capella":
|
|
||||||
version = Opt.some(ConsensusFork.Capella)
|
|
||||||
of "deneb":
|
|
||||||
version = Opt.some(ConsensusFork.Deneb)
|
|
||||||
else:
|
|
||||||
reader.raiseUnexpectedValue("Incorrect version field value")
|
reader.raiseUnexpectedValue("Incorrect version field value")
|
||||||
of "data":
|
of "data":
|
||||||
when (blockType is ProduceBlockResponseV2) or
|
when (blockType is ProduceBlockResponseV2) or
|
||||||
|
|
Loading…
Reference in New Issue