Merge pull request #994 from ethcore/ommited
import route contains ommited blocks
This commit is contained in:
commit
a73323e64c
@ -186,7 +186,7 @@ impl BlockProvider for BlockChain {
|
||||
self.extras_db.exists_with_cache(&self.block_details, hash)
|
||||
}
|
||||
|
||||
// We do not store tracing information.
|
||||
/// We do not store tracing information.
|
||||
fn have_tracing(&self) -> bool { false }
|
||||
|
||||
/// Get raw block data
|
||||
@ -541,7 +541,7 @@ impl BlockChain {
|
||||
Some(ret)
|
||||
}
|
||||
|
||||
/// Get inserted block info which is critical to preapre extras updates.
|
||||
/// Get inserted block info which is critical to prepare extras updates.
|
||||
fn block_info(&self, block_bytes: &[u8]) -> BlockInfo {
|
||||
let block = BlockView::new(block_bytes);
|
||||
let header = block.header_view();
|
||||
@ -950,21 +950,25 @@ mod tests {
|
||||
assert_eq!(ir1, ImportRoute {
|
||||
enacted: vec![b1_hash],
|
||||
retracted: vec![],
|
||||
omitted: vec![],
|
||||
});
|
||||
|
||||
assert_eq!(ir2, ImportRoute {
|
||||
enacted: vec![b2_hash],
|
||||
retracted: vec![],
|
||||
omitted: vec![],
|
||||
});
|
||||
|
||||
assert_eq!(ir3b, ImportRoute {
|
||||
enacted: vec![b3b_hash],
|
||||
retracted: vec![],
|
||||
omitted: vec![],
|
||||
});
|
||||
|
||||
assert_eq!(ir3a, ImportRoute {
|
||||
enacted: vec![b3a_hash],
|
||||
retracted: vec![b3b_hash],
|
||||
omitted: vec![],
|
||||
});
|
||||
|
||||
assert_eq!(bc.best_block_hash(), best_block_hash);
|
||||
|
@ -26,6 +26,8 @@ pub struct ImportRoute {
|
||||
pub retracted: Vec<H256>,
|
||||
/// Blocks that were validated by new block.
|
||||
pub enacted: Vec<H256>,
|
||||
/// Blocks which are neither retracted nor enacted.
|
||||
pub omitted: Vec<H256>,
|
||||
}
|
||||
|
||||
impl ImportRoute {
|
||||
@ -33,6 +35,7 @@ impl ImportRoute {
|
||||
ImportRoute {
|
||||
retracted: vec![],
|
||||
enacted: vec![],
|
||||
omitted: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,13 +46,19 @@ impl From<BlockInfo> for ImportRoute {
|
||||
BlockLocation::CanonChain => ImportRoute {
|
||||
retracted: vec![],
|
||||
enacted: vec![info.hash],
|
||||
omitted: vec![],
|
||||
},
|
||||
BlockLocation::Branch => ImportRoute {
|
||||
retracted: vec![],
|
||||
enacted: vec![],
|
||||
omitted: vec![info.hash],
|
||||
},
|
||||
BlockLocation::Branch => ImportRoute::none(),
|
||||
BlockLocation::BranchBecomingCanonChain(mut data) => {
|
||||
data.enacted.push(info.hash);
|
||||
ImportRoute {
|
||||
retracted: data.retracted,
|
||||
enacted: data.enacted,
|
||||
omitted: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +77,7 @@ mod tests {
|
||||
assert_eq!(ImportRoute::none(), ImportRoute {
|
||||
enacted: vec![],
|
||||
retracted: vec![],
|
||||
omitted: vec![],
|
||||
});
|
||||
}
|
||||
|
||||
@ -80,7 +90,11 @@ mod tests {
|
||||
location: BlockLocation::Branch,
|
||||
};
|
||||
|
||||
assert_eq!(ImportRoute::from(info), ImportRoute::none());
|
||||
assert_eq!(ImportRoute::from(info), ImportRoute {
|
||||
retracted: vec![],
|
||||
enacted: vec![],
|
||||
omitted: vec![H256::from(U256::from(1))],
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -95,6 +109,7 @@ mod tests {
|
||||
assert_eq!(ImportRoute::from(info), ImportRoute {
|
||||
retracted: vec![],
|
||||
enacted: vec![H256::from(U256::from(1))],
|
||||
omitted: vec![],
|
||||
});
|
||||
}
|
||||
|
||||
@ -114,6 +129,7 @@ mod tests {
|
||||
assert_eq!(ImportRoute::from(info), ImportRoute {
|
||||
retracted: vec![H256::from(U256::from(3)), H256::from(U256::from(4))],
|
||||
enacted: vec![H256::from(U256::from(1)), H256::from(U256::from(2))],
|
||||
omitted: vec![],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user