Skip to content

Commit

Permalink
add missing locks (#144)
Browse files Browse the repository at this point in the history
* add missing locks in GetMasternodeOutpointAndKeys

properly locks mutex before selecing masternode collaterals
with AvailableCoins

* add missing lock in miner

properly lock mutex before calling TestBlockValidity
  • Loading branch information
rikublock authored and durkmurder committed Oct 15, 2019
1 parent 2e022e9 commit 43ed8dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,12 @@ void static XSNMiner(const CChainParams& chainparams, CConnman& connman,
}

// check if block is valid
CValidationState state;
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
{
LOCK(cs_main);
CValidationState state;
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
}
}

// process proof of stake block
Expand Down
5 changes: 4 additions & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5300,7 +5300,10 @@ bool CWallet::GetMasternodeOutpointAndKeys(COutPoint& outpointRet, CPubKey& pubK
std::vector<COutput> vPossibleCoins;
CCoinControl coinControl;
coinControl.nCoinType = ONLY_MASTERNODE_COLLATERAL;
AvailableCoins(vPossibleCoins, true, &coinControl, 1, MAX_MONEY, MAX_MONEY, 0, 0, 9999999);
{
LOCK2(cs_main, cs_wallet);
AvailableCoins(vPossibleCoins, true, &coinControl, 1, MAX_MONEY, MAX_MONEY, 0, 0, 9999999);
}
if(vPossibleCoins.empty()) {
LogPrintf("CWallet::GetMasternodeOutpointAndKeys -- Could not locate any valid masternode vin\n");
return false;
Expand Down

0 comments on commit 43ed8dd

Please sign in to comment.