Skip to content

Commit 87f37e2

Browse files
committed
Merge pull request #6519
7f1f8f5 Move mempool rejections to new debug category (Wladimir J. van der Laan) 66daed5 Add information to errors in ConnectBlock, CheckBlock (Wladimir J. van der Laan) 6cab808 Remove most logging from transaction validation (Wladimir J. van der Laan) 9003c7c Add function to convert CValidationState to a human-readable message (Wladimir J. van der Laan) dc58258 Introduce REJECT_INTERNAL codes for local AcceptToMempool errors (Wladimir J. van der Laan) fbf44e6 Add debug message to CValidationState for optional extra information (Wladimir J. van der Laan)
2 parents 3eaaf71 + 7f1f8f5 commit 87f37e2

File tree

4 files changed

+80
-77
lines changed

4 files changed

+80
-77
lines changed

src/consensus/validation.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,27 @@ class CValidationState {
3030
std::string strRejectReason;
3131
unsigned int chRejectCode;
3232
bool corruptionPossible;
33+
std::string strDebugMessage;
3334
public:
3435
CValidationState() : mode(MODE_VALID), nDoS(0), chRejectCode(0), corruptionPossible(false) {}
3536
bool DoS(int level, bool ret = false,
36-
unsigned int chRejectCodeIn=0, std::string strRejectReasonIn="",
37-
bool corruptionIn=false) {
37+
unsigned int chRejectCodeIn=0, const std::string &strRejectReasonIn="",
38+
bool corruptionIn=false,
39+
const std::string &strDebugMessageIn="") {
3840
chRejectCode = chRejectCodeIn;
3941
strRejectReason = strRejectReasonIn;
4042
corruptionPossible = corruptionIn;
43+
strDebugMessage = strDebugMessageIn;
4144
if (mode == MODE_ERROR)
4245
return ret;
4346
nDoS += level;
4447
mode = MODE_INVALID;
4548
return ret;
4649
}
4750
bool Invalid(bool ret = false,
48-
unsigned int _chRejectCode=0, std::string _strRejectReason="") {
49-
return DoS(0, ret, _chRejectCode, _strRejectReason);
51+
unsigned int _chRejectCode=0, const std::string &_strRejectReason="",
52+
const std::string &_strDebugMessage="") {
53+
return DoS(0, ret, _chRejectCode, _strRejectReason, false, _strDebugMessage);
5054
}
5155
bool Error(const std::string& strRejectReasonIn) {
5256
if (mode == MODE_VALID)
@@ -75,6 +79,7 @@ class CValidationState {
7579
}
7680
unsigned int GetRejectCode() const { return chRejectCode; }
7781
std::string GetRejectReason() const { return strRejectReason; }
82+
std::string GetDebugMessage() const { return strDebugMessage; }
7883
};
7984

8085
#endif // BITCOIN_CONSENSUS_VALIDATION_H

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ std::string HelpMessage(HelpMessageMode mode)
373373
strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", 1));
374374
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
375375
}
376-
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, net, proxy, prune"; // Don't translate these and qt below
376+
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune"; // Don't translate these and qt below
377377
if (mode == HMM_BITCOIN_QT)
378378
debugCategories += ", qt";
379379
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +

0 commit comments

Comments
 (0)