Skip to content

Commit 52dba35

Browse files
committed
Make CheckMerkleBranch private in CAuxPow.
CheckMerkleBranch is a utility method that was previously removed in upstream Bitcoin, but is still needed for auxpow's. For that reason, it was moved to be a static function in CAuxPow. It can, however, be private to explicitly enforce that it is only used there.
1 parent e607061 commit 52dba35

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/auxpow.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ class CAuxPow
130130
/** Parent block header (on which the real PoW is done). */
131131
CPureBlockHeader parentBlock;
132132

133+
/**
134+
* Check a merkle branch. This used to be in CBlock, but was removed
135+
* upstream. Thus include it here now.
136+
*/
137+
static uint256 CheckMerkleBranch (uint256 hash,
138+
const std::vector<uint256>& vMerkleBranch,
139+
int nIndex);
140+
133141
friend UniValue AuxpowToJSON(const CAuxPow& auxpow);
134142
friend class auxpow_tests::CAuxPowForTest;
135143

@@ -185,14 +193,6 @@ class CAuxPow
185193
*/
186194
static int getExpectedIndex (uint32_t nNonce, int nChainId, unsigned h);
187195

188-
/**
189-
* Check a merkle branch. This used to be in CBlock, but was removed
190-
* upstream. Thus include it here now.
191-
*/
192-
static uint256 CheckMerkleBranch (uint256 hash,
193-
const std::vector<uint256>& vMerkleBranch,
194-
int nIndex);
195-
196196
/**
197197
* Constructs a minimal CAuxPow object for the given block header and
198198
* returns it. The caller should make sure to set the auxpow flag on the

src/test/auxpow_tests.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class CAuxPowForTest : public CAuxPow
6060
using CAuxPow::nChainIndex;
6161
using CAuxPow::parentBlock;
6262

63+
using CAuxPow::CheckMerkleBranch;
64+
6365
};
6466

6567
/**
@@ -178,7 +180,8 @@ CAuxpowBuilder::buildAuxpowChain (const uint256& hashAux, unsigned h, int index)
178180
auxpowChainMerkleBranch.push_back (ArithToUint256 (arith_uint256 (i)));
179181

180182
const uint256 hash
181-
= CAuxPow::CheckMerkleBranch (hashAux, auxpowChainMerkleBranch, index);
183+
= CAuxPowForTest::CheckMerkleBranch (hashAux, auxpowChainMerkleBranch,
184+
index);
182185

183186
valtype res = ToByteVector (hash);
184187
std::reverse (res.begin (), res.end ());

0 commit comments

Comments
 (0)