diff options
author | jtimon <jtimon@blockstream.io> | 2014-09-03 02:52:01 +0200 |
---|---|---|
committer | jtimon <jtimon@blockstream.io> | 2014-09-08 22:14:24 +0200 |
commit | 6db83db3eb96809da3e680464b152f82785e38e6 (patch) | |
tree | e74fd80fe789c3550d862d088e2d6b86be547e14 /src/main.cpp | |
parent | eecd3c0fb0625b036f68a7830dda8edde21fcb90 (diff) |
Decouple CChain from mapBlockIndex
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index a3b31b719d..108f8e0823 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -431,18 +431,19 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const { return CBlockLocator(vHave); } -CBlockIndex *CChain::FindFork(const CBlockLocator &locator) const { +CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) +{ // Find the first block the caller has in the main chain BOOST_FOREACH(const uint256& hash, locator.vHave) { BlockMap::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; - if (Contains(pindex)) + if (chain.Contains(pindex)) return pindex; } } - return Genesis(); + return chain.Genesis(); } const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const { @@ -3672,7 +3673,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, LOCK(cs_main); // Find the last block the caller has in the main chain - CBlockIndex* pindex = chainActive.FindFork(locator); + CBlockIndex* pindex = FindForkInGlobalIndex(chainActive, locator); // Send the rest of the chain if (pindex) @@ -3719,7 +3720,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else { // Find the last block the caller has in the main chain - pindex = chainActive.FindFork(locator); + pindex = FindForkInGlobalIndex(chainActive, locator); if (pindex) pindex = chainActive.Next(pindex); } |