aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-10-12 15:18:08 +0200
committerPieter Wuille <sipa@ulyssis.org>2013-10-15 11:09:29 +0200
commite4daecda0bcd47a2672eb625232f00e388a3cd87 (patch)
treecc58a832fbf4ccac98abdb3c2c6f16fe120f3c45 /src/main.h
parentb2ba55c42b563418e7be4adb38cdbf1852e6c78d (diff)
Reimplement CBlockLocator's chain-related logic in CChain.
This removes a few unused CBlockLocator methods, and moves the construction and fork-finding logic to CChain (which can do these more efficiently, as it has a height-indexable chain available). It also makes CBlockLocator independent from the validation code.
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/main.h b/src/main.h
index 46d629044a..1cddbae567 100644
--- a/src/main.h
+++ b/src/main.h
@@ -22,6 +22,7 @@ class CBlock;
class CBlockIndex;
class CKeyItem;
class CReserveKey;
+class CBlockLocator;
class CAddress;
class CInv;
@@ -1033,6 +1034,12 @@ public:
/** Set/initialize a chain with a given tip. Returns the forking point. */
CBlockIndex *SetTip(CBlockIndex *pindex);
+
+ /** Return a CBlockLocator that refers to a block in this chain (by default the tip). */
+ CBlockLocator GetLocator(const CBlockIndex *pindex = NULL) const;
+
+ /** Find the last common block between this chain and a locator. */
+ CBlockIndex *FindFork(const CBlockLocator &locator) const;
};
/** The currently-connected chain of blocks. */
@@ -1051,13 +1058,6 @@ protected:
public:
CBlockLocator() {}
- explicit CBlockLocator(const CBlockIndex* pindex)
- {
- Set(pindex);
- }
-
- explicit CBlockLocator(uint256 hashBlock);
-
CBlockLocator(const std::vector<uint256>& vHaveIn)
{
vHave = vHaveIn;
@@ -1080,16 +1080,7 @@ public:
return vHave.empty();
}
- /** Given a block initialises the locator to that point in the chain. */
- void Set(const CBlockIndex* pindex);
- /** Returns the distance in blocks this locator is from our chain head. */
- int GetDistanceBack();
- /** Returns the first best-chain block the locator contains. */
- CBlockIndex* GetBlockIndex();
- /** Returns the hash of the first best chain block the locator contains. */
- uint256 GetBlockHash();
- /** Returns the height of the first best chain block the locator has. */
- int GetHeight();
+ friend class CChain;
};