Refactor <V, B> to type V, type B

This commit is contained in:
Luke Parker
2022-10-16 03:55:39 -04:00
parent a5f1ddaf1b
commit f79321233d
4 changed files with 43 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
use tendermint_machine::ext::{BlockError, Block, Network};
use tendermint_machine::ext::*;
#[derive(Clone, PartialEq)]
struct TestBlock {
@@ -15,7 +15,10 @@ impl Block for TestBlock {
}
struct TestNetwork;
impl Network<u16, TestBlock> for TestNetwork {
impl Network for TestNetwork {
type ValidatorId = u16;
type Block = TestBlock;
fn total_weight(&self) -> u64 {
5
}
@@ -23,6 +26,10 @@ impl Network<u16, TestBlock> for TestNetwork {
[1, 1, 1, 1, 1][usize::try_from(id).unwrap()]
}
fn proposer(&self, number: BlockNumber, round: Round) -> u16 {
u16::try_from((number.0 + u32::from(round.0)) % 5).unwrap()
}
fn validate(&mut self, block: TestBlock) -> Result<(), BlockError> {
block.valid
}