Refactor out external parts to generics

Also creates a dedicated file for the message log.
This commit is contained in:
Luke Parker
2022-10-16 03:29:55 -04:00
parent 1237c41c53
commit a5f1ddaf1b
5 changed files with 243 additions and 158 deletions

View File

@@ -0,0 +1,29 @@
use tendermint_machine::ext::{BlockError, Block, Network};
#[derive(Clone, PartialEq)]
struct TestBlock {
id: u32,
valid: Result<(), BlockError>,
}
impl Block for TestBlock {
type Id = u32;
fn id(&self) -> u32 {
self.id
}
}
struct TestNetwork;
impl Network<u16, TestBlock> for TestNetwork {
fn total_weight(&self) -> u64 {
5
}
fn weight(&self, id: u16) -> u64 {
[1, 1, 1, 1, 1][usize::try_from(id).unwrap()]
}
fn validate(&mut self, block: TestBlock) -> Result<(), BlockError> {
block.valid
}
}