From 2cf1573c52ad0188fc94ea643295c2f8e0e2cc66 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 21 Oct 2022 02:13:44 -0400 Subject: [PATCH] Dummy Weights --- substrate/consensus/src/weights.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 substrate/consensus/src/weights.rs diff --git a/substrate/consensus/src/weights.rs b/substrate/consensus/src/weights.rs new file mode 100644 index 00000000..d9d5c405 --- /dev/null +++ b/substrate/consensus/src/weights.rs @@ -0,0 +1,21 @@ +// TODO + +use tendermint_machine::ext::{BlockNumber, Round, Weights}; + +const VALIDATORS: usize = 1; + +pub(crate) struct TendermintWeights; +impl Weights for TendermintWeights { + type ValidatorId = u16; + + fn total_weight(&self) -> u64 { + VALIDATORS.try_into().unwrap() + } + fn weight(&self, id: u16) -> u64 { + [1; VALIDATORS][usize::try_from(id).unwrap()] + } + + fn proposer(&self, number: BlockNumber, round: Round) -> u16 { + u16::try_from((number.0 + u64::from(round.0)) % u64::try_from(VALIDATORS).unwrap()).unwrap() + } +}