aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorPieter Wuille <sipa@ulyssis.org>2014-06-25 00:56:47 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-06-29 21:51:54 +0200
commitc9a0918330f31dcb1d5e86b56af63c3f521d3cf2 (patch)
tree66ff2a641ab21415f41dd6c602538a406ab206ec /src/main.h
parentaa815647005bc8467f467c35a9e617794446cd64 (diff)
Add a skiplist to the CBlockIndex structure.
This allows fast (O(log n)) access to far predecessor blocks. Use it to speed up CChain::FindFork and CChain::GetLocator.
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main.h b/src/main.h
index 9487078b74..1af86b065f 100644
--- a/src/main.h
+++ b/src/main.h
@@ -677,6 +677,9 @@ public:
// pointer to the index of the predecessor of this block
CBlockIndex* pprev;
+ // pointer to the index of some further predecessor of this block
+ CBlockIndex* pskip;
+
// height of the entry in the chain. The genesis block has height 0
int nHeight;
@@ -716,6 +719,7 @@ public:
{
phashBlock = NULL;
pprev = NULL;
+ pskip = NULL;
nHeight = 0;
nFile = 0;
nDataPos = 0;
@@ -737,6 +741,7 @@ public:
{
phashBlock = NULL;
pprev = NULL;
+ pskip = NULL;
nHeight = 0;
nFile = 0;
nDataPos = 0;
@@ -869,9 +874,14 @@ public:
}
return false;
}
-};
+ // Build the skiplist pointer for this entry.
+ void BuildSkip();
+ // Efficiently find an ancestor of this block.
+ CBlockIndex* GetAncestor(int height);
+ const CBlockIndex* GetAncestor(int height) const;
+};
/** Used to marshal pointers into hashes for db storage. */
class CDiskBlockIndex : public CBlockIndex