From d5555de1b9280e4e6780d4a33187e5e57bcdbbba Mon Sep 17 00:00:00 2001 From: debris Date: Sun, 24 Apr 2016 19:40:04 +0200 Subject: [PATCH 1/3] import route contains ommited blocks --- ethcore/src/blockchain/blockchain.rs | 8 ++++++-- ethcore/src/blockchain/import_route.rs | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 2258db22e..27cc74e9b 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -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![], + ommited: vec![], }); assert_eq!(ir2, ImportRoute { enacted: vec![b2_hash], retracted: vec![], + ommited: vec![], }); assert_eq!(ir3b, ImportRoute { enacted: vec![b3b_hash], retracted: vec![], + ommited: vec![], }); assert_eq!(ir3a, ImportRoute { enacted: vec![b3a_hash], retracted: vec![b3b_hash], + ommited: vec![], }); assert_eq!(bc.best_block_hash(), best_block_hash); diff --git a/ethcore/src/blockchain/import_route.rs b/ethcore/src/blockchain/import_route.rs index 253c4024a..eecf4f76d 100644 --- a/ethcore/src/blockchain/import_route.rs +++ b/ethcore/src/blockchain/import_route.rs @@ -26,6 +26,8 @@ pub struct ImportRoute { pub retracted: Vec, /// Blocks that were validated by new block. pub enacted: Vec, + /// Blocks which are neither retracted nor enacted. + pub ommited: Vec, } impl ImportRoute { @@ -33,6 +35,7 @@ impl ImportRoute { ImportRoute { retracted: vec![], enacted: vec![], + ommited: vec![], } } } @@ -43,13 +46,19 @@ impl From for ImportRoute { BlockLocation::CanonChain => ImportRoute { retracted: vec![], enacted: vec![info.hash], + ommited: vec![], + }, + BlockLocation::Branch => ImportRoute { + retracted: vec![], + enacted: vec![], + ommited: vec![info.hash], }, - BlockLocation::Branch => ImportRoute::none(), BlockLocation::BranchBecomingCanonChain(mut data) => { data.enacted.push(info.hash); ImportRoute { retracted: data.retracted, enacted: data.enacted, + ommited: vec![], } } } @@ -68,6 +77,7 @@ mod tests { assert_eq!(ImportRoute::none(), ImportRoute { enacted: vec![], retracted: vec![], + ommited: 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![], + ommited: 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))], + ommited: 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))], + ommited: vec![], }); } } From 0810de4415c36f831813aecaa24b466e005a71cc Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 24 Apr 2016 22:16:06 +0100 Subject: [PATCH 2/3] Fix spelling of "omitted" --- ethcore/src/blockchain/blockchain.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 27cc74e9b..ad74447a1 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -950,25 +950,25 @@ mod tests { assert_eq!(ir1, ImportRoute { enacted: vec![b1_hash], retracted: vec![], - ommited: vec![], + omitted: vec![], }); assert_eq!(ir2, ImportRoute { enacted: vec![b2_hash], retracted: vec![], - ommited: vec![], + omitted: vec![], }); assert_eq!(ir3b, ImportRoute { enacted: vec![b3b_hash], retracted: vec![], - ommited: vec![], + omitted: vec![], }); assert_eq!(ir3a, ImportRoute { enacted: vec![b3a_hash], retracted: vec![b3b_hash], - ommited: vec![], + omitted: vec![], }); assert_eq!(bc.best_block_hash(), best_block_hash); From 242b986196b60751ed86866f1cdff9dca98cdc38 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 24 Apr 2016 22:16:34 +0100 Subject: [PATCH 3/3] Fix spelling of "omitted" --- ethcore/src/blockchain/import_route.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ethcore/src/blockchain/import_route.rs b/ethcore/src/blockchain/import_route.rs index eecf4f76d..17cbd8caf 100644 --- a/ethcore/src/blockchain/import_route.rs +++ b/ethcore/src/blockchain/import_route.rs @@ -27,7 +27,7 @@ pub struct ImportRoute { /// Blocks that were validated by new block. pub enacted: Vec, /// Blocks which are neither retracted nor enacted. - pub ommited: Vec, + pub omitted: Vec, } impl ImportRoute { @@ -35,7 +35,7 @@ impl ImportRoute { ImportRoute { retracted: vec![], enacted: vec![], - ommited: vec![], + omitted: vec![], } } } @@ -46,19 +46,19 @@ impl From for ImportRoute { BlockLocation::CanonChain => ImportRoute { retracted: vec![], enacted: vec![info.hash], - ommited: vec![], + omitted: vec![], }, BlockLocation::Branch => ImportRoute { retracted: vec![], enacted: vec![], - ommited: vec![info.hash], + omitted: vec![info.hash], }, BlockLocation::BranchBecomingCanonChain(mut data) => { data.enacted.push(info.hash); ImportRoute { retracted: data.retracted, enacted: data.enacted, - ommited: vec![], + omitted: vec![], } } } @@ -77,7 +77,7 @@ mod tests { assert_eq!(ImportRoute::none(), ImportRoute { enacted: vec![], retracted: vec![], - ommited: vec![], + omitted: vec![], }); } @@ -93,7 +93,7 @@ mod tests { assert_eq!(ImportRoute::from(info), ImportRoute { retracted: vec![], enacted: vec![], - ommited: vec![H256::from(U256::from(1))], + omitted: vec![H256::from(U256::from(1))], }); } @@ -109,7 +109,7 @@ mod tests { assert_eq!(ImportRoute::from(info), ImportRoute { retracted: vec![], enacted: vec![H256::from(U256::from(1))], - ommited: vec![], + omitted: vec![], }); } @@ -129,7 +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))], - ommited: vec![], + omitted: vec![], }); } }