Move new block notif out of sumtree lock. Fix #180

This commit is contained in:
Ignotus Peverell 2017-10-15 20:38:41 +00:00
parent dd90031902
commit aa520d34d5
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
2 changed files with 8 additions and 9 deletions

View file

@ -129,6 +129,13 @@ impl Chain {
let mut head = chain_head.lock().unwrap();
*head = tip.clone();
}
// notifying other parts of the system of the update
if !opts.intersects(SYNC) {
// broadcast the block
let adapter = self.adapter.clone();
adapter.block_accepted(&b);
}
self.check_orphans();
}
Ok(None) => {}
@ -177,7 +184,6 @@ impl Chain {
pipe::BlockContext {
opts: opts_in,
store: self.store.clone(),
adapter: self.adapter.clone(),
head: head,
pow_verifier: self.pow_verifier,
sumtrees: self.sumtrees.clone(),

View file

@ -36,8 +36,6 @@ pub struct BlockContext {
pub opts: Options,
/// The store
pub store: Arc<ChainStore>,
/// The adapter
pub adapter: Arc<ChainAdapter>,
/// The head
pub head: Tip,
/// The POW verification function
@ -294,11 +292,6 @@ fn validate_block(b: &Block,
fn add_block(b: &Block, ctx: &mut BlockContext) -> Result<(), Error> {
ctx.store.save_block(b).map_err(&Error::StoreErr)?;
if !ctx.opts.intersects(SYNC) {
// broadcast the block
let adapter = ctx.adapter.clone();
adapter.block_accepted(b);
}
Ok(())
}