mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
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.
This commit is contained in:
committed by
Pieter Wuille
parent
aa81564700
commit
c9a0918330
14
src/main.h
14
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,10 +874,15 @@ 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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user