diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index 16d3e2216..eb9d66124 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -309,15 +309,10 @@ impl ClosedBlock { pub fn try_seal(self, engine: &Engine, seal: Vec) -> Result { let mut s = self; s.block.base.header.set_seal(seal); - if let Err(e) = engine.verify_block_basic(&s.block.base.header, None) { - debug!("Failed to try_seal: {:?}", e); - return Err(s); + match engine.verify_block_seal(&s.block.base.header) { + Err(_) => Err(s), + _ => Ok(SealedBlock { block: s.block, uncle_bytes: s.uncle_bytes }), } - if let Err(e) = engine.verify_block_unordered(&s.block.base.header, None) { - debug!("Failed to try_seal: {:?}", e); - return Err(s); - } - Ok(SealedBlock { block: s.block, uncle_bytes: s.uncle_bytes }) } /// Drop this object and return the underlieing database. diff --git a/ethcore/src/engine.rs b/ethcore/src/engine.rs index c57be3cdb..a05c78ff5 100644 --- a/ethcore/src/engine.rs +++ b/ethcore/src/engine.rs @@ -74,6 +74,13 @@ pub trait Engine : Sync + Send { /// Verify a particular transaction is valid. fn verify_transaction(&self, _t: &SignedTransaction, _header: &Header) -> Result<(), Error> { Ok(()) } + /// Verify the seal of a block. This is an auxilliary method that actually just calls other `verify_` methods + /// to get the job done. By default it must pass `verify_basic` and `verify_block_unordered`. If more or fewer + /// methods are needed for an Engine, this may be overridden. + fn verify_block_seal(&self, header: &Header) -> Result<(), Error> { + self.verify_block_basic(header, None).and_then(|_| self.verify_block_unordered(header, None)) + } + /// Don't forget to call Super::populateFromParent when subclassing & overriding. // TODO: consider including State in the params. fn populate_from_parent(&self, _header: &mut Header, _parent: &Header) {}