aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorjtimon <jtimon@blockstream.io>2014-09-03 02:20:09 +0200
committerjtimon <jtimon@blockstream.io>2014-09-08 22:17:19 +0200
commite8b5f0d549b1b76611c7374bed9ceec7d09fa847 (patch)
treea35ca887cbbe54978bf94943a5a250d6ec30540e /src/main.cpp
parent6db83db3eb96809da3e680464b152f82785e38e6 (diff)
Move CBlockIndex, CChain and related code out of main
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp54
1 files changed, 0 insertions, 54 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 108f8e0823..5210f8ef55 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -385,52 +385,6 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
nodeSignals.FinalizeNode.disconnect(&FinalizeNode);
}
-//////////////////////////////////////////////////////////////////////////////
-//
-// CChain implementation
-//
-
-CBlockIndex *CChain::SetTip(CBlockIndex *pindex) {
- if (pindex == NULL) {
- vChain.clear();
- return NULL;
- }
- vChain.resize(pindex->nHeight + 1);
- while (pindex && vChain[pindex->nHeight] != pindex) {
- vChain[pindex->nHeight] = pindex;
- pindex = pindex->pprev;
- }
- return pindex;
-}
-
-CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
- int nStep = 1;
- std::vector<uint256> vHave;
- vHave.reserve(32);
-
- if (!pindex)
- pindex = Tip();
- while (pindex) {
- vHave.push_back(pindex->GetBlockHash());
- // Stop when we have added the genesis block.
- if (pindex->nHeight == 0)
- break;
- // Exponentially larger steps back, plus the genesis block.
- int nHeight = std::max(pindex->nHeight - nStep, 0);
- if (Contains(pindex)) {
- // Use O(1) CChain index if possible.
- pindex = (*this)[nHeight];
- } else {
- // Otherwise, use O(log n) skiplist.
- pindex = pindex->GetAncestor(nHeight);
- }
- if (vHave.size() > 10)
- nStep *= 2;
- }
-
- return CBlockLocator(vHave);
-}
-
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator)
{
// Find the first block the caller has in the main chain
@@ -446,14 +400,6 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
return chain.Genesis();
}
-const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
- if (pindex->nHeight > Height())
- pindex = pindex->GetAncestor(Height());
- while (pindex && !Contains(pindex))
- pindex = pindex->pprev;
- return pindex;
-}
-
CCoinsViewCache *pcoinsTip = NULL;
CBlockTreeDB *pblocktree = NULL;