From 6ff75324404e6ef71b4299879068e4cbc580cbcf Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Tue, 28 Nov 2023 13:08:25 +0200 Subject: [PATCH] Improve `ConsensusConfig.protocol_version` conversion --- node/actors/executor/src/config/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/node/actors/executor/src/config/mod.rs b/node/actors/executor/src/config/mod.rs index 09d3bded..abf1fda9 100644 --- a/node/actors/executor/src/config/mod.rs +++ b/node/actors/executor/src/config/mod.rs @@ -31,11 +31,12 @@ impl ProtoFmt for ConsensusConfig { type Proto = proto::ConsensusConfig; fn read(proto: &Self::Proto) -> anyhow::Result { - let protocol_version = proto.protocol_version.context("protocol_version")?; Ok(Self { key: read_required_text(&proto.key).context("key")?, public_addr: read_required_text(&proto.public_addr).context("public_addr")?, - protocol_version: validator::ProtocolVersion::try_from(protocol_version) + protocol_version: required(&proto.protocol_version) + .copied() + .and_then(validator::ProtocolVersion::try_from) .context("protocol_version")?, }) }