From 42df98450c3c2edcf9c1898d20c23cb012928b32 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 2 Mar 2016 18:05:47 +0100 Subject: [PATCH] Include uncles in exclused. --- ethcore/src/blockchain/blockchain.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index d40a34b0c..6779051e2 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -78,7 +78,7 @@ pub trait BlockProvider { } /// Get a list of uncles for a given block. - /// Returns None if block deos not exist. + /// Returns None if block does not exist. fn uncles(&self, hash: &H256) -> Option> { self.block(hash).map(|bytes| BlockView::new(&bytes).uncles()) } @@ -491,7 +491,7 @@ impl BlockChain { self.extras_db.write(batch).unwrap(); } - pub fn ancestry_iter(&self, first: H256) -> AncestryIter { + pub fn ancestry_iter(&self, first: H256) -> Option { AncestryIter { current: first, chain: &self, @@ -503,7 +503,8 @@ impl BlockChain { let uncle_generations = 6usize; /* { - // Find great-uncles (or second-cousins or whatever they are) - children of great-grandparents, great-great-grandparents... that were not already uncles in previous generations. + // Find great-uncles (or second-cousins or whatever they are) - + // children of great-grandparents, great-great-grandparents... that were not already uncles in previous generations. clog(StateDetail) << "Checking " << m_previousBlock.hash() << ", parent=" << m_previousBlock.parentHash(); h256Hash excluded = _bc.allKinFrom(m_currentBlock.parentHash(), 6); auto p = m_previousBlock.parentHash(); @@ -523,7 +524,11 @@ impl BlockChain { } } */ - let _excluded = self.ancestry_iter(parent.clone()).take(uncle_generations).collect::>(); + let _excluded = self + .ancestry_iter(parent.clone()) + .take(uncle_generations) + .flat_map(|h| self.uncle_hashes(&h).iter().chain(&[h])) + .collect::>(); Vec::new() }