Skip to content

Commit 02cc068

Browse files
Merge #928: [Logging] Define a STAKING log category.
06dcbc3 [Logging] Define a STAKING log category. (Zannick) Pull request description: ### Problem ### `BLOCKCREATION` is a very noisy log category. It includes DarkGravityWave logs (which are noisy), staking messages, and generic block creation logs. ### Root Cause ### Not enough log categories. ### Solution ### Added a new log category specific to staking. Staking-relevant messages that were previously `BLOCKCREATION` have been moved over. ### Bounty PR ### None ### Bounty Payment Address ## `sv1qqpswvjy7s9yrpcmrt3fu0kd8rutrdlq675ntyjxjzn09f965z9dutqpqgg85esvg8mhmyka5kq5vae0qnuw4428vs9d2gu4nz643jv5a72wkqqq73mnxr` ### Unit Testing Results ### Tested on win10 x64 WLS Ubuntu 20.04: built and ran unittests individually, comparing results to a previous master commit. Tree-SHA512: 43517034e8a47488c349ee84f63d9cd3ade21214eb05488ffb8d5c99fb7ba63d15daefb985ea7f10326ad5f3c359b0a40b7cf829ada1dd79f8e7006a977cf69b
2 parents 1e2b060 + 06dcbc3 commit 02cc068

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/logging.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const CLogCategoryDesc LogCategories[] =
124124
{BCLog::CHAINSCORE, "chainscore"},
125125
{BCLog::STAGING, "staging"},
126126
{BCLog::MINING, "mining"},
127+
{BCLog::STAKING, "staking"},
127128
{BCLog::ALL, "1"},
128129
{BCLog::ALL, "all"},
129130
};

src/logging.h

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ namespace BCLog {
5858
CHAINSCORE = (1 << 23),
5959
STAGING = (1 << 24),
6060
MINING = (1 << 25),
61+
STAKING = (1 << 26),
6162
ALL = ~(uint32_t)0,
6263
};
6364

src/miner.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
515515
}
516516
auto spend = TxInToZerocoinSpend(pblock->vtx[1]->vin[0]);
517517
if (!spend) {
518-
LogPrint(BCLog::BLOCKCREATION, "%s: failed to get spend for txin", __func__);
518+
LogPrint(BCLog::STAKING, "%s: failed to get spend for txin", __func__);
519519
return nullptr;
520520
}
521521

@@ -525,17 +525,17 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
525525
#ifdef ENABLE_WALLET
526526
if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET) || !pwalletMain->GetZerocoinKey(bnSerial, key)) {
527527
#endif
528-
LogPrint(BCLog::BLOCKCREATION, "%s: Failed to get zerocoin key from wallet!\n", __func__);
528+
LogPrint(BCLog::STAKING, "%s: Failed to get zerocoin key from wallet!\n", __func__);
529529
return nullptr;
530530
#ifdef ENABLE_WALLET
531531
}
532532
#endif
533533

534534
if (!key.Sign(pblock->GetHash(), pblock->vchBlockSig)) {
535-
LogPrint(BCLog::BLOCKCREATION, "%s: Failed to sign block hash\n", __func__);
535+
LogPrint(BCLog::STAKING, "%s: Failed to sign block hash\n", __func__);
536536
return nullptr;
537537
}
538-
LogPrint(BCLog::BLOCKCREATION, "%s: FOUND STAKE!!\n block: \n%s\n", __func__, pblock->ToString());
538+
LogPrint(BCLog::STAKING, "%s: FOUND STAKE!!\n block: \n%s\n", __func__, pblock->ToString());
539539
}
540540

541541
if (pindexPrev && pindexPrev != chainActive.Tip()) {
@@ -926,7 +926,7 @@ void BitcoinMiner(std::shared_ptr<CReserveScript> coinbaseScript, bool fProofOfS
926926
auto it = mapStakeHashCounter.find(nHeight);
927927
if (it != mapStakeHashCounter.end() && it->second != nStakeHashesLast) {
928928
nStakeHashesLast = it->second;
929-
LogPrint(BCLog::BLOCKCREATION, "%s: Tried %d stake hashes for block %d last=%d\n", __func__, nStakeHashesLast, nHeight+1, mapHashedBlocks.at(hashBestBlock));
929+
LogPrint(BCLog::STAKING, "%s: Tried %d stake hashes for block %d last=%d\n", __func__, nStakeHashesLast, nHeight+1, mapHashedBlocks.at(hashBestBlock));
930930
}
931931
// wait half of the nHashDrift with max wait of 3 minutes
932932
int rand = GetRandInt(20); // add small randomness to prevent all nodes from being on too similar of timing

src/wallet/wallet.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3908,7 +3908,7 @@ bool CWallet::CreateCoinStake(const CBlockIndex* pindexBest, unsigned int nBits,
39083908
LOCK(cs_main);
39093909
//Double check that this will pass time requirements
39103910
if (nTxNewTime <= nTimeMinBlock) {
3911-
LogPrint(BCLog::BLOCKCREATION, "CreateCoinStake() : kernel found, but it is too far in the past \n");
3911+
LogPrint(BCLog::STAKING, "%s : kernel found, but it is too far in the past \n", __func__);
39123912
continue;
39133913
}
39143914
nHeight = chainActive.Height();
@@ -4008,7 +4008,7 @@ bool CWallet::SelectStakeCoins(std::list<std::unique_ptr<ZerocoinStake> >& listI
40084008
}
40094009
}
40104010

4011-
LogPrint(BCLog::BLOCKCREATION, "%s: FOUND %d STAKABLE ZEROCOINS\n", __func__, listInputs.size());
4011+
LogPrint(BCLog::STAKING, "%s: FOUND %d STAKABLE ZEROCOINS\n", __func__, listInputs.size());
40124012

40134013
return true;
40144014
}

0 commit comments

Comments
 (0)