Skip to content

Commit 092b58d

Browse files
author
jtimon
committed
CBlockIndex::GetBlockWork() + GetProofIncrement(nBits) -> GetBlockProof(CBlockIndex)
1 parent 22c4272 commit 092b58d

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

src/chain.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ class CBlockIndex
217217
return (int64_t)nTime;
218218
}
219219

220-
uint256 GetBlockWork() const
221-
{
222-
return GetProofIncrement(nBits);
223-
}
224-
225220
enum { nMedianTimeSpan=11 };
226221

227222
int64_t GetMedianTimePast() const

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ void CheckForkWarningConditions()
12051205
if (pindexBestForkTip && chainActive.Height() - pindexBestForkTip->nHeight >= 72)
12061206
pindexBestForkTip = NULL;
12071207

1208-
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.Tip()->nChainWork + (chainActive.Tip()->GetBlockWork() * 6)))
1208+
if (pindexBestForkTip || (pindexBestInvalid && pindexBestInvalid->nChainWork > chainActive.Tip()->nChainWork + (GetBlockProof(*chainActive.Tip()) * 6)))
12091209
{
12101210
if (!fLargeWorkForkFound)
12111211
{
@@ -1256,7 +1256,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip)
12561256
// We define it this way because it allows us to only store the highest fork tip (+ base) which meets
12571257
// the 7-block condition and from this always have the most-likely-to-cause-warning fork
12581258
if (pfork && (!pindexBestForkTip || (pindexBestForkTip && pindexNewForkTip->nHeight > pindexBestForkTip->nHeight)) &&
1259-
pindexNewForkTip->nChainWork - pfork->nChainWork > (pfork->GetBlockWork() * 7) &&
1259+
pindexNewForkTip->nChainWork - pfork->nChainWork > (GetBlockProof(*pfork) * 7) &&
12601260
chainActive.Height() - pindexNewForkTip->nHeight < 72)
12611261
{
12621262
pindexBestForkTip = pindexNewForkTip;
@@ -2095,7 +2095,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
20952095
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
20962096
pindexNew->BuildSkip();
20972097
}
2098-
pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + pindexNew->GetBlockWork();
2098+
pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + GetBlockProof(*pindexNew);
20992099
pindexNew->RaiseValidity(BLOCK_VALID_TREE);
21002100
if (pindexBestHeader == NULL || pindexBestHeader->nChainWork < pindexNew->nChainWork)
21012101
pindexBestHeader = pindexNew;
@@ -2788,7 +2788,7 @@ bool static LoadBlockIndexDB()
27882788
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
27892789
{
27902790
CBlockIndex* pindex = item.second;
2791-
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + pindex->GetBlockWork();
2791+
pindex->nChainWork = (pindex->pprev ? pindex->pprev->nChainWork : 0) + GetBlockProof(*pindex);
27922792
if (pindex->nStatus & BLOCK_HAVE_DATA) {
27932793
if (pindex->pprev) {
27942794
if (pindex->pprev->nChainTx) {

src/pow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
9797
return true;
9898
}
9999

100-
uint256 GetProofIncrement(unsigned int nBits)
100+
uint256 GetBlockProof(const CBlockIndex& block)
101101
{
102102
uint256 bnTarget;
103103
bool fNegative;
104104
bool fOverflow;
105-
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
105+
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
106106
if (fNegative || fOverflow || bnTarget == 0)
107107
return 0;
108108
// We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256

src/pow.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
1616

1717
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
1818
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
19-
20-
uint256 GetProofIncrement(unsigned int nBits);
19+
uint256 GetBlockProof(const CBlockIndex& block);
2120

2221
#endif // BITCOIN_POW_H

0 commit comments

Comments
 (0)