Skip to content

Commit

Permalink
[Wallet] Reduce shutdown delays when mining
Browse files Browse the repository at this point in the history
  • Loading branch information
CaveSpectre11 committed Jan 20, 2021
1 parent d64124f commit f71b152
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ void BitcoinMiner(std::shared_ptr<CReserveScript> coinbaseScript, bool fProofOfS
enablewallet = !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
#endif

while (GenerateActive() || (fProofOfStake && enablewallet))
while (!ShutdownRequested() && (GenerateActive() || (fProofOfStake && enablewallet)))
{
boost::this_thread::interruption_point();
#ifdef ENABLE_WALLET
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
uint256 mix_hash;
while (nMaxTries > 0 && pblock->nNonce64 < nInnerLoopCount &&
!CheckProofOfWork(ProgPowHash(*pblock, mix_hash), pblock->nBits,
Params().GetConsensus(), CBlockHeader::PROGPOW_BLOCK)) {
Params().GetConsensus(), CBlockHeader::PROGPOW_BLOCK) && !ShutdownRequested()) {
++pblock->nNonce64;
--nMaxTries;
}
Expand All @@ -246,7 +246,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen

bnTarget.SetCompact(pblock->nBits, &fNegative, &fOverflow);

while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount) {
while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount && !ShutdownRequested()) {
// RandomX hash
uint256 hash_blob = pblock->GetRandomXHeaderHash();
randomx_calculate_hash(GetMyMachineValidating(), &hash_blob, sizeof uint256(), hash);
Expand All @@ -263,7 +263,7 @@ UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGen
} else if (pblock->IsSha256D() && pblock->nTime >= Params().PowUpdateTimestamp()) {
while (nMaxTries > 0 && pblock->nNonce64 < nInnerLoopCount &&
!CheckProofOfWork(pblock->GetSha256DPoWHash(), pblock->nBits,
Params().GetConsensus(), CBlockHeader::SHA256D_BLOCK)) {
Params().GetConsensus(), CBlockHeader::SHA256D_BLOCK) && !ShutdownRequested()) {
++pblock->nNonce64;
--nMaxTries;
}
Expand Down

0 comments on commit f71b152

Please sign in to comment.