mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Add an assert to verify proposed children aren't best
This commit is contained in:
@@ -198,7 +198,6 @@ where
|
|||||||
Err(Error::InvalidJustification)?;
|
Err(Error::InvalidJustification)?;
|
||||||
}
|
}
|
||||||
self.verify_justification(block.header.hash(), next.unwrap())?;
|
self.verify_justification(block.header.hash(), next.unwrap())?;
|
||||||
|
|
||||||
block.finalized = true;
|
block.finalized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,6 +331,7 @@ where
|
|||||||
async fn validate(&mut self, block: &B) -> Result<(), BlockError> {
|
async fn validate(&mut self, block: &B) -> Result<(), BlockError> {
|
||||||
let hash = block.hash();
|
let hash = block.hash();
|
||||||
let (header, body) = block.clone().deconstruct();
|
let (header, body) = block.clone().deconstruct();
|
||||||
|
let parent = *header.parent_hash();
|
||||||
*self.importing_block.write().unwrap() = Some(hash);
|
*self.importing_block.write().unwrap() = Some(hash);
|
||||||
self.queue.write().await.as_mut().unwrap().import_blocks(
|
self.queue.write().await.as_mut().unwrap().import_blocks(
|
||||||
// We do not want this block, which hasn't been confirmed, to be broadcast over the net
|
// We do not want this block, which hasn't been confirmed, to be broadcast over the net
|
||||||
@@ -353,11 +353,12 @@ where
|
|||||||
}],
|
}],
|
||||||
);
|
);
|
||||||
|
|
||||||
if ImportFuture::new(hash, self.queue.write().await.as_mut().unwrap()).await {
|
if !ImportFuture::new(hash, self.queue.write().await.as_mut().unwrap()).await {
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
assert_eq!(self.client.info().best_hash, parent);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn add_block(&mut self, block: B, commit: Commit<TendermintSigner>) -> B {
|
async fn add_block(&mut self, block: B, commit: Commit<TendermintSigner>) -> B {
|
||||||
|
|||||||
Reference in New Issue
Block a user