diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 3c15486a12..134f24135c 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -22,6 +22,7 @@ use std::thread::{self, JoinHandle}; pub struct ChainService { shared: Shared, notify: NotifyController, + block_verifier: BlockVerifier>, } #[derive(Clone)] @@ -59,7 +60,12 @@ pub struct BlockInsertionResult { impl ChainService { pub fn new(shared: Shared, notify: NotifyController) -> ChainService { - ChainService { shared, notify } + let block_verifier = BlockVerifier::new(shared.clone()); + ChainService { + shared, + notify, + block_verifier, + } } pub fn start( @@ -92,7 +98,7 @@ impl ChainService { fn process_block(&mut self, block: Arc) -> Result<(), ProcessBlockError> { debug!(target: "chain", "begin processing block: {}", block.header().hash()); if self.shared.consensus().verification { - BlockVerifier::new(self.shared.clone()) + self.block_verifier .verify(&block) .map_err(ProcessBlockError::Verification)? }