Skip to content

Commit 06dcbc3

Browse files
committed
[Logging] Define a STAKING log category.
This allows separation of log messages related to staking from log messages about block creation, which currently includes all generic block creation messages as well as DarkGravityWave difficulty measurements.
1 parent 5852183 commit 06dcbc3

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()) {
@@ -932,7 +932,7 @@ void BitcoinMiner(std::shared_ptr<CReserveScript> coinbaseScript, bool fProofOfS
932932
auto it = mapStakeHashCounter.find(nHeight);
933933
if (it != mapStakeHashCounter.end() && it->second != nStakeHashesLast) {
934934
nStakeHashesLast = it->second;
935-
LogPrint(BCLog::BLOCKCREATION, "%s: Tried %d stake hashes for block %d last=%d\n", __func__, nStakeHashesLast, nHeight+1, mapHashedBlocks.at(hashBestBlock));
935+
LogPrint(BCLog::STAKING, "%s: Tried %d stake hashes for block %d last=%d\n", __func__, nStakeHashesLast, nHeight+1, mapHashedBlocks.at(hashBestBlock));
936936
}
937937
// wait half of the nHashDrift with max wait of 3 minutes
938938
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)