Skip to content

Commit

Permalink
Merge #1820: sporks: remove unneeded chainActive access.
Browse files Browse the repository at this point in the history
fdf5c6e sporks: remove unneeded chainActive access. (furszy)

Pull request description:

  Removed a not needed `ChainActive` access in `ProcessSpork`. One `cs_main` lock less.

ACKs for top commit:
  random-zebra:
    utACK fdf5c6e
  Fuzzbawls:
    utACK fdf5c6e

Tree-SHA512: 59974328de396f348afc7bef79272e7ce116f6f7313625a6997997f3cdf67ac7417827e973f920d5fa7961050e65ad5c8e5545f9af149d13dc7ec004a2528550
  • Loading branch information
furszy committed Sep 2, 2020
2 parents d675fa3 + fdf5c6e commit 846dca7
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "main.h"
#include "masternode-budget.h"
#include "messagesigner.h"
#include "net.h"
#include "spork.h"
Expand Down Expand Up @@ -76,14 +75,6 @@ void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStr
{
if (fLiteMode) return; // disable all masternode related functionality

int nChainHeight = 0;
{
LOCK(cs_main);
if (chainActive.Tip() == nullptr)
return;
nChainHeight = chainActive.Height();
}

if (strCommand == NetMsgType::SPORK) {
CSporkMessage spork;
vRecv >> spork;
Expand Down Expand Up @@ -120,13 +111,13 @@ void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStr
return;
} else {
// update active spork
LogPrintf("%s : got updated spork %d (%s) with value %d (signed at %d) - block %d \n", __func__,
spork.nSporkID, sporkName, spork.nValue, spork.nTimeSigned, nChainHeight);
LogPrintf("%s : got updated spork %d (%s) with value %d (signed at %d) \n", __func__,
spork.nSporkID, sporkName, spork.nValue, spork.nTimeSigned);
}
} else {
// spork is not active
LogPrintf("%s : got new spork %d (%s) with value %d (signed at %d) - block %d \n", __func__,
spork.nSporkID, sporkName, spork.nValue, spork.nTimeSigned, nChainHeight);
LogPrintf("%s : got new spork %d (%s) with value %d (signed at %d) \n", __func__,
spork.nSporkID, sporkName, spork.nValue, spork.nTimeSigned);
}
}

Expand Down

0 comments on commit 846dca7

Please sign in to comment.