verify_external in verifier trait
This commit is contained in:
parent
715d5daafe
commit
e1fa4ab8ec
@ -380,6 +380,12 @@ impl Client {
|
||||
return Err(());
|
||||
};
|
||||
|
||||
let verify_external_result = self.verifier.verify_block_external(header, &block.bytes, engine);
|
||||
if let Err(e) = verify_external_result {
|
||||
warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
|
||||
return Err(());
|
||||
};
|
||||
|
||||
// Check if Parent is in chain
|
||||
let chain_has_parent = chain.block_header(header.parent_hash());
|
||||
if let Some(parent) = chain_has_parent {
|
||||
|
@ -34,4 +34,8 @@ impl Verifier for CanonVerifier {
|
||||
fn verify_block_final(&self, expected: &Header, got: &Header) -> Result<(), Error> {
|
||||
verification::verify_block_final(expected, got)
|
||||
}
|
||||
|
||||
fn verify_block_external(&self, header: &Header, bytes: &[u8], engine: &Engine) -> Result<(), Error> {
|
||||
engine.verify_block_external(header, Some(bytes))
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,8 @@ impl Verifier for NoopVerifier {
|
||||
fn verify_block_final(&self, _expected: &Header, _got: &Header) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_block_external(&self, _header: &Header, _bytes: &[u8], _engine: &Engine) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,6 @@ pub trait Verifier: Send + Sync {
|
||||
fn verify_block_family(&self, header: &Header, bytes: &[u8], engine: &Engine, bc: &BlockProvider) -> Result<(), Error>;
|
||||
/// Do a final verification check for an enacted header vs its expected counterpart.
|
||||
fn verify_block_final(&self, expected: &Header, got: &Header) -> Result<(), Error>;
|
||||
/// Verify a block, inspecing external state.
|
||||
fn verify_block_external(&self, header: &Header, bytes: &[u8], engine: &Engine) -> Result<(), Error>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user