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:
Ignotus Peverell
2017-07-27 23:47:33 +00:00
parent 22bff54f66
commit b3e224b439
2 changed files with 5 additions and 6 deletions
+4 -2
View File
@@ -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
View File
@@ -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);