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:
Etan Kissling 2024-03-02 23:45:20 +01:00 committed by GitHub
parent b4db011daf
commit 542854e743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 12 deletions

View File

@ -1413,18 +1413,8 @@ template prepareForkedBlockReading(blockType: typedesc,
reader.raiseUnexpectedField("Multiple version fields found",
blockType.name)
let vres = reader.readValue(string).toLowerAscii()
case vres
of "phase0":
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:
version = ConsensusFork.init(vres)
if version.isNone():
reader.raiseUnexpectedValue("Incorrect version field value")
of "data":
when (blockType is ProduceBlockResponseV2) or