Skip to content

Commit

Permalink
Improve ConsensusConfig.protocol_version conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
slowli committed Nov 28, 2023
1 parent d0f85d9 commit 6ff7532
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions node/actors/executor/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ impl ProtoFmt for ConsensusConfig {
type Proto = proto::ConsensusConfig;

fn read(proto: &Self::Proto) -> anyhow::Result<Self> {
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")?,
})
}
Expand Down

0 comments on commit 6ff7532

Please sign in to comment.