Implement block proposal logic

This commit is contained in:
Luke Parker
2022-10-21 23:36:24 -04:00
parent adfc9a5d1d
commit bf5bdb89c2
9 changed files with 91 additions and 23 deletions

View File

@@ -186,6 +186,9 @@ pub trait Network: Send + Sync {
/// consider it valid and created a commit for it. This deviates from the paper which will have a
/// local node refuse to decide on a block it considers invalid. This library acknowledges the
/// network did decide on it, leaving handling of it to the network, and outside of this scope.
fn add_block(&mut self, block: Self::Block, commit: Commit<Self::SignatureScheme>)
-> Self::Block;
async fn add_block(
&mut self,
block: Self::Block,
commit: Commit<Self::SignatureScheme>,
) -> Self::Block;
}

View File

@@ -318,7 +318,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
};
debug_assert!(machine.network.read().await.verify_commit(block.id(), &commit));
let proposal = machine.network.write().await.add_block(block, commit);
let proposal = machine.network.write().await.add_block(block, commit).await;
machine.reset(proposal).await;
}
Err(TendermintError::Malicious(validator)) => {

View File

@@ -113,7 +113,11 @@ impl Network for TestNetwork {
block.valid
}
fn add_block(&mut self, block: TestBlock, commit: Commit<TestSignatureScheme>) -> TestBlock {
async fn add_block(
&mut self,
block: TestBlock,
commit: Commit<TestSignatureScheme>,
) -> TestBlock {
dbg!("Adding ", &block);
assert!(block.valid.is_ok());
assert!(self.verify_commit(block.id(), &commit));