@@ -381,18 +381,6 @@ CNodeState* State(NodeId pnode)
381381 return &it->second ;
382382}
383383
384- int GetHeight ()
385- {
386- while (true ) {
387- TRY_LOCK (cs_main, lockMain);
388- if (!lockMain) {
389- MilliSleep (50 );
390- continue ;
391- }
392- return chainActive.Height ();
393- }
394- }
395-
396384void UpdatePreferredDownload (CNode* node, CNodeState* state)
397385{
398386 nPreferredDownload -= state->fPreferredDownload ;
@@ -3044,7 +3032,7 @@ static bool ActivateBestChainStep(CValidationState& state, CBlockIndex* pindexMo
30443032 * or an activated best chain. pblock is either NULL or a pointer to a block
30453033 * that is already loaded (to avoid loading it again from disk).
30463034 */
3047- bool ActivateBestChain (CValidationState& state, const CBlock* pblock, bool fAlreadyChecked , CConnman* connman, CBudgetManager* pbudget )
3035+ bool ActivateBestChain (CValidationState& state, const CBlock* pblock, bool fAlreadyChecked , CConnman* connman)
30483036{
30493037 // Note that while we're often called here from ProcessNewBlock, this is
30503038 // far from a guarantee. Things in the P2P/RPC will often end up calling
@@ -3101,8 +3089,6 @@ bool ActivateBestChain(CValidationState& state, const CBlock* pblock, bool fAlre
31013089 // Notifications/callbacks that can run without cs_main
31023090 if (connman)
31033091 connman->SetBestHeight (pindexNewTip->nHeight );
3104- if (pbudget)
3105- pbudget->SetBestHeight (pindexNewTip->nHeight );
31063092
31073093 // Always notify the UI if a new block tip was connected
31083094 if (pindexFork != pindexNewTip) {
@@ -4171,8 +4157,8 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, const CBlock* pblock
41714157
41724158 // For now, we need the tip to know whether p2pkh block signatures are accepted or not.
41734159 // After 5.0, this can be removed and replaced by the enforcement block time.
4174- const CBlockIndex* pindexPrev = chainActive.Tip () ;
4175- const bool enableP2PKH = (pindexPrev) ? consensus.NetworkUpgradeActive (pindexPrev-> nHeight + 1 , Consensus::UPGRADE_V5_DUMMY) : false ;
4160+ const int newHeight = chainActive.Height () + 1 ;
4161+ const bool enableP2PKH = consensus.NetworkUpgradeActive (newHeight , Consensus::UPGRADE_V5_DUMMY);
41764162 if (!CheckBlockSignature (*pblock, enableP2PKH))
41774163 return error (" %s : bad proof-of-stake block signature" , __func__);
41784164
@@ -4199,7 +4185,7 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, const CBlock* pblock
41994185 if (pindex && pfrom) {
42004186 mapBlockSource[pindex->GetBlockHash ()] = pfrom->GetId ();
42014187 }
4202- CheckBlockIndex ();
4188+ CheckBlockIndex ();
42034189 if (!ret) {
42044190 // Check spamming
42054191 if (pindex && pfrom && GetBoolArg (" -blockspamfilter" , DEFAULT_BLOCK_SPAM_FILTER)) {
@@ -4223,13 +4209,13 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, const CBlock* pblock
42234209 }
42244210 }
42254211
4226- if (!ActivateBestChain (state, pblock, checked, connman, &budget ))
4212+ if (!ActivateBestChain (state, pblock, checked, connman))
42274213 return error (" %s : ActivateBestChain failed" , __func__);
42284214
42294215 if (!fLiteMode ) {
42304216 if (masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) {
4231- masternodePayments.ProcessBlock (GetHeight () + 10 );
4232- budget.NewBlock ();
4217+ masternodePayments.ProcessBlock (newHeight + 10 );
4218+ budget.NewBlock (newHeight );
42334219 }
42344220 }
42354221
@@ -4245,7 +4231,7 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, const CBlock* pblock
42454231 pwalletMain->AutoCombineDust (connman);
42464232 }
42474233
4248- LogPrintf (" %s : ACCEPTED Block %ld in %ld milliseconds with size=%d\n " , __func__, GetHeight () , GetTimeMillis () - nStartTime,
4234+ LogPrintf (" %s : ACCEPTED Block %ld in %ld milliseconds with size=%d\n " , __func__, newHeight , GetTimeMillis () - nStartTime,
42494235 GetSerializeSize (*pblock, SER_DISK, CLIENT_VERSION));
42504236
42514237 return true ;
0 commit comments