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:
+4
-2
@@ -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();
|
||||
}
|
||||
|
||||
+1
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user