mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 22:41:25 +02:00
mining: clarify SubmitBlock result handling
Make the submitBlock return value explicit and check that it stays consistent with the BIP22 reason string, so future changes do not return success with a reason or failure without one. Report "inconclusive" when no specific block rejection reason is available. This covers blocks accepted without being connected, and processing failures where ProcessNewBlock returns false without an invalid BlockChecked result, for example when ActivateBestChain fails after BlockChecked reported a valid block. Also document why no validation-interface queue drain is needed before unregistering: BlockChecked is emitted synchronously by ProcessNewBlock, unlike most validation signals.
This commit is contained in:
@@ -1031,7 +1031,9 @@ public:
|
||||
// ProcessNewBlock() can accept and store a block before it is checked
|
||||
// for validity. Treat duplicates as errors for mining clients, and only
|
||||
// return success when validation completed without setting a reason.
|
||||
return accepted && new_block && reason.empty();
|
||||
const bool result{accepted && new_block && reason.empty()};
|
||||
CHECK_NONFATAL(result == reason.empty());
|
||||
return result;
|
||||
}
|
||||
|
||||
const NodeContext* context() override { return &m_node; }
|
||||
|
||||
Reference in New Issue
Block a user