Skip to content

Commit be63fb7

Browse files
Merge #920: [Logging][Mining] Add BCLog::MINING category.
8dfd59a [Logging][Mining] Add BCLog::MINING category. (Zannick) Pull request description: ### Problem ### Mining code uses the `BLOCKCREATION` logging category, which includes logging about difficulty targets, staking, zerocoins, etc, making it harder to investigate mining-specific issues. ### Root Cause ### Using the `BLOCKCREATION` category for lots of different information. ### Solution ### Adds a new logging category `MINING` to aid debugging mining specifically without including block template creation logs that may be noisier. Converts most logs in BitcoinMiner and RandomXMiner to use this category instead of `BLOCKCREATION`. Fixes one unlikely logging statement to include the function name. ### Bounty Payment Address ### `sv1qqpswvjy7s9yrpcmrt3fu0kd8rutrdlq675ntyjxjzn09f965z9dutqpqgg85esvg8mhmyka5kq5vae0qnuw4428vs9d2gu4nz643jv5a72wkqqq73mnxr` ### Unit Testing Results ### Tested by running and sending the command `logging [\"mining\"]` to enable. Tree-SHA512: 15cfa486d5dc6d763d0c14b9d7b6da9c2008cd3b4e35029d9ddec1b8ce2192bcb1da8794838af76e1b091346ab93499e9898a2adcf27ff97dbc5dfec287ee0fe
2 parents 01b2ee5 + 8dfd59a commit be63fb7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/logging.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ const CLogCategoryDesc LogCategories[] =
123123
{BCLog::BLOCKCREATION, "blockcreation"},
124124
{BCLog::CHAINSCORE, "chainscore"},
125125
{BCLog::STAGING, "staging"},
126+
{BCLog::MINING, "mining"},
126127
{BCLog::ALL, "1"},
127128
{BCLog::ALL, "all"},
128129
};

src/logging.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace BCLog {
5757
BLOCKCREATION = (1 << 22),
5858
CHAINSCORE = (1 << 23),
5959
STAGING = (1 << 24),
60+
MINING = (1 << 25),
6061
ALL = ~(uint32_t)0,
6162
};
6263

src/miner.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ void BitcoinMiner(std::shared_ptr<CReserveScript> coinbaseScript, bool fProofOfS
10111011
++pblock->nNonce;
10121012
}
10131013
} else {
1014-
LogPrintf("%s: Unknown hashing algorithm found!\n");
1014+
LogPrintf("%s: Unknown hashing algorithm found!\n", __func__);
10151015
return;
10161016
}
10171017

@@ -1023,16 +1023,16 @@ void BitcoinMiner(std::shared_ptr<CReserveScript> coinbaseScript, bool fProofOfS
10231023
if (!nTimeDuration) nTimeDuration = 1;
10241024
nHashSpeed = arith_uint256(nHashes/1000/nTimeDuration).getdouble();
10251025
}
1026-
LogPrint(BCLog::BLOCKCREATION, "%s: PoW Hashspeed %d kh/s\n", __func__, nHashSpeed);
10271026

1027+
LogPrint(BCLog::MINING, "%s: PoW Hashspeed %d kh/s\n", __func__, nHashSpeed);
10281028
if (nTries == nInnerLoopCount) {
10291029
continue;
10301030
}
10311031
}
10321032

10331033
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
10341034
if (!ProcessNewBlock(Params(), shared_pblock, true, nullptr)) {
1035-
LogPrint(BCLog::BLOCKCREATION, "%s : Failed to process new block\n", __func__);
1035+
LogPrint(BCLog::MINING, "%s: Failed to process new block\n", __func__);
10361036
continue;
10371037
}
10381038

@@ -1142,8 +1142,8 @@ void BitcoinRandomXMiner(std::shared_ptr<CReserveScript> coinbaseScript, int vm_
11421142
nHashSpeed = arith_uint256(nHashes/nTimeDuration).getdouble();
11431143
}
11441144
}
1145-
LogPrint(BCLog::BLOCKCREATION, "%s: RandomX PoW Hashspeed %d hashes/s\n", __func__, nHashSpeed);
11461145

1146+
LogPrint(BCLog::MINING, "%s: RandomX PoW Hashspeed %d hashes/s\n", __func__, nHashSpeed);
11471147
if (nTries == nInnerLoopCount) {
11481148
continue;
11491149
}
@@ -1155,7 +1155,7 @@ void BitcoinRandomXMiner(std::shared_ptr<CReserveScript> coinbaseScript, int vm_
11551155

11561156
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
11571157
if (!ProcessNewBlock(Params(), shared_pblock, true, nullptr)) {
1158-
LogPrint(BCLog::BLOCKCREATION, "%s: Failed to process new block\n", __func__);
1158+
LogPrint(BCLog::MINING, "%s: Failed to process new block\n", __func__);
11591159
continue;
11601160
}
11611161

0 commit comments

Comments
 (0)