Skip to content

Commit

Permalink
fix: shared data clone
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWaWaR committed Jan 2, 2019
1 parent 146925a commit 4bf9555
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use std::thread::{self, JoinHandle};
pub struct ChainService<CI> {
shared: Shared<CI>,
notify: NotifyController,
block_verifier: BlockVerifier<Shared<CI>>,
}

#[derive(Clone)]
Expand Down Expand Up @@ -59,7 +60,12 @@ pub struct BlockInsertionResult {

impl<CI: ChainIndex + 'static> ChainService<CI> {
pub fn new(shared: Shared<CI>, notify: NotifyController) -> ChainService<CI> {
ChainService { shared, notify }
let block_verifier = BlockVerifier::new(shared.clone());
ChainService {
shared,
notify,
block_verifier,
}
}

pub fn start<S: ToString>(
Expand Down Expand Up @@ -92,7 +98,7 @@ impl<CI: ChainIndex + 'static> ChainService<CI> {
fn process_block(&mut self, block: Arc<Block>) -> 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)?
}
Expand Down

0 comments on commit 4bf9555

Please sign in to comment.