mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Move new block notif out of sumtree lock. Fix #180
This commit is contained in:
parent
dd90031902
commit
aa520d34d5
2 changed files with 8 additions and 9 deletions
|
@ -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) => {}
|
||||
|
@ -140,7 +147,7 @@ impl Chain {
|
|||
Err(ref e) => {
|
||||
info!(
|
||||
LOGGER,
|
||||
"Rejected block {} at {} : {:?}",
|
||||
"Rejected block {} at {}: {:?}",
|
||||
b.hash(),
|
||||
b.header.height,
|
||||
e
|
||||
|
@ -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(),
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue