mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Merge bitcoin/bitcoin#32386: mining: rename gbt_force and gbt_force_name
0750249289mining: document gbt_rule_value helper (Sjors Provoost)5e87c3ec09scripted-diff: rename gbt_force and gbt_force_name (Sjors Provoost) Pull request description: The term "force" is ambiguous and not used in [BIP9](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate-changes) where there ! rule prefix is introduced. E.g. this code is hard to read: ```cpp if (!gbt_force) { s.insert(s.begin(), '!'); ``` Additionally, #29039 renamed `gbt_vb_name` to `gbt_force_name` which, at least for me, further increased the confusion. This is a pure (variable rename) refactor (plus documentation) and does not change behavior. Reminder of how to verify a scripted diff: ```sh test/lint/commit-script-check.sh origin/master..HEAD ``` ACKs for top commit: achow101: ACK0750249289janb84: ACK [0750249](0750249289) musaHaruna: ACK [0750249](0750249289) glozow: ACK0750249289, seems sensible Tree-SHA512: 8c88a273a3b36040f6c641843bd20579d0065b051aad4b39fc14f0d2af2808690dff6772bd8b1a4d9699b72279a700d2661012651bc315433a123dcc8996adaa
This commit is contained in:
@@ -596,10 +596,11 @@ static UniValue BIP22ValidationResult(const BlockValidationState& state)
|
||||
return "valid?";
|
||||
}
|
||||
|
||||
static std::string gbt_force_name(const std::string& name, bool gbt_force)
|
||||
// Prefix rule name with ! if not optional, see BIP9
|
||||
static std::string gbt_rule_value(const std::string& name, bool gbt_optional_rule)
|
||||
{
|
||||
std::string s{name};
|
||||
if (!gbt_force) {
|
||||
if (!gbt_optional_rule) {
|
||||
s.insert(s.begin(), '!');
|
||||
}
|
||||
return s;
|
||||
@@ -955,8 +956,8 @@ static RPCHelpMan getblocktemplate()
|
||||
const auto gbtstatus = chainman.m_versionbitscache.GBTStatus(*pindexPrev, consensusParams);
|
||||
|
||||
for (const auto& [name, info] : gbtstatus.signalling) {
|
||||
vbavailable.pushKV(gbt_force_name(name, info.gbt_force), info.bit);
|
||||
if (!info.gbt_force && !setClientRules.count(name)) {
|
||||
vbavailable.pushKV(gbt_rule_value(name, info.gbt_optional_rule), info.bit);
|
||||
if (!info.gbt_optional_rule && !setClientRules.count(name)) {
|
||||
// If the client doesn't support this, don't indicate it in the [default] version
|
||||
block.nVersion &= ~info.mask;
|
||||
}
|
||||
@@ -964,16 +965,16 @@ static RPCHelpMan getblocktemplate()
|
||||
|
||||
for (const auto& [name, info] : gbtstatus.locked_in) {
|
||||
block.nVersion |= info.mask;
|
||||
vbavailable.pushKV(gbt_force_name(name, info.gbt_force), info.bit);
|
||||
if (!info.gbt_force && !setClientRules.count(name)) {
|
||||
vbavailable.pushKV(gbt_rule_value(name, info.gbt_optional_rule), info.bit);
|
||||
if (!info.gbt_optional_rule && !setClientRules.count(name)) {
|
||||
// If the client doesn't support this, don't indicate it in the [default] version
|
||||
block.nVersion &= ~info.mask;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [name, info] : gbtstatus.active) {
|
||||
aRules.push_back(gbt_force_name(name, info.gbt_force));
|
||||
if (!info.gbt_force && !setClientRules.count(name)) {
|
||||
aRules.push_back(gbt_rule_value(name, info.gbt_optional_rule));
|
||||
if (!info.gbt_optional_rule && !setClientRules.count(name)) {
|
||||
// Not supported by the client; make sure it's safe to proceed
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Support for '%s' rule requires explicit client support", name));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user