mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
Minor fixes to orphan handling
Fixed sync pathway in validation pipeline not returning the proper orphan error. Reduced chain head lock span to prevent deadlock on reentrancy.
This commit is contained in:
parent
22bff54f66
commit
b3e224b439
2 changed files with 5 additions and 6 deletions
|
@ -125,8 +125,10 @@ impl Chain {
|
|||
Ok(Some(ref tip)) => {
|
||||
// block got accepted and extended the head, updating our head
|
||||
let chain_head = self.head.clone();
|
||||
let mut head = chain_head.lock().unwrap();
|
||||
*head = tip.clone();
|
||||
{
|
||||
let mut head = chain_head.lock().unwrap();
|
||||
*head = tip.clone();
|
||||
}
|
||||
|
||||
self.check_orphans();
|
||||
}
|
||||
|
|
|
@ -164,10 +164,7 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
|
|||
/// Fully validate the block content.
|
||||
fn validate_block(b: &Block, ctx: &mut BlockContext) -> Result<(), Error> {
|
||||
if b.header.height > ctx.head.height + 1 {
|
||||
// check orphan again, an orphan coming out of order from sync will have
|
||||
// bypassed header checks
|
||||
// TODO actually handle orphans and add them to a size-limited set
|
||||
return Err(Error::Unfit("orphan".to_string()));
|
||||
return Err(Error::Orphan);
|
||||
}
|
||||
|
||||
let curve = secp::Secp256k1::with_caps(secp::ContextFlag::Commit);
|
||||
|
|
Loading…
Reference in a new issue