Skip to content

Commit 016a60e

Browse files
committed
[Wallet][RPC] Remove GetStakingBalance calls to get staking status
MintableCoins() already gets the staking balance and checks it against the reserve balance. No need to do it twice. This affects both BitcoinMiner and getstakingstatus RPC.
1 parent cf5f2d2 commit 016a60e

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/miner.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,6 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake)
662662
// Each thread has its own key and counter
663663
CReserveKey reservekey(pwallet);
664664
unsigned int nExtraNonce = 0;
665-
bool fColdStake = GetBoolArg("-coldstaking", true);
666-
CAmount stakingBalance = 0;
667665

668666
while (fGenerateBitcoins || fProofOfStake) {
669667
CBlockIndex* pindexPrev = GetChainTip();
@@ -683,18 +681,16 @@ void BitcoinMiner(CWallet* pwallet, bool fProofOfStake)
683681
{
684682
nMintableLastCheck = GetTime();
685683
fMintableCoins = pwallet->MintableCoins();
686-
stakingBalance = pwallet->GetStakingBalance(fColdStake);
687684
}
688685

689686
while (vNodes.empty() || pwallet->IsLocked() || !fMintableCoins ||
690-
(stakingBalance > 0 && nReserveBalance >= stakingBalance) || masternodeSync.NotCompleted()) {
687+
masternodeSync.NotCompleted()) {
691688
MilliSleep(5000);
692689
// Do a separate 1 minute check here to ensure fMintableCoins is updated
693690
if (!fMintableCoins && (GetTime() - nMintableLastCheck > 1 * 60)) // 1 minute check time
694691
{
695692
nMintableLastCheck = GetTime();
696693
fMintableCoins = pwallet->MintableCoins();
697-
stakingBalance = pwallet->GetStakingBalance(fColdStake);
698694
}
699695
}
700696

src/rpc/misc.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,7 @@ UniValue getstakingstatus(const UniValue& params, bool fHelp)
600600
" \"haveconnections\": true|false, (boolean) if network connections are present\n"
601601
" \"mnsync\": true|false, (boolean) if masternode data is synced\n"
602602
" \"walletunlocked\": true|false, (boolean) if the wallet is unlocked\n"
603-
" \"mintablecoins\": true|false, (boolean) if the wallet has mintable coins\n"
604-
" \"enoughcoins\": true|false, (boolean) if available coins are greater than reserve balance\n"
603+
" \"mintablecoins\": true|false, (boolean) if the wallet has mintable balance (greater than reserve balance)\n"
605604
" \"hashLastStakeAttempt\": xxx (hex string) hash of last block on top of which the miner attempted to stake\n"
606605
" \"heightLastStakeAttempt\": n (integer) height of last block on top of which the miner attempted to stake\n"
607606
" \"timeLastStakeAttempt\": n (integer) time of last attempted stake\n"
@@ -623,7 +622,6 @@ UniValue getstakingstatus(const UniValue& params, bool fHelp)
623622
obj.push_back(Pair("mnsync", masternodeSync.IsSynced()));
624623
obj.push_back(Pair("walletunlocked", !pwalletMain->IsLocked()));
625624
obj.push_back(Pair("mintablecoins", pwalletMain->MintableCoins()));
626-
obj.push_back(Pair("enoughcoins", nReserveBalance <= pwalletMain->GetStakingBalance(GetBoolArg("-coldstaking", true))));
627625
uint256 lastHash = pwalletMain->pStakerStatus->GetLastHash();
628626
obj.push_back(Pair("hashLastStakeAttempt", lastHash.GetHex()));
629627
obj.push_back(Pair("heightLastStakeAttempt", (mapBlockIndex.count(lastHash) > 0 ?

0 commit comments

Comments
 (0)