@@ -565,10 +565,10 @@ static UniValue BIP22ValidationResult(const BlockValidationState& state)
565
565
return " valid?" ;
566
566
}
567
567
568
- static std::string gbt_vb_name (const Consensus::DeploymentPos pos) {
569
- const struct VBDeploymentInfo & vbinfo = VersionBitsDeploymentInfo[pos];
570
- std::string s = vbinfo. name ;
571
- if (!vbinfo. gbt_force ) {
568
+ static std::string gbt_force_name (const std::string& name, bool gbt_force)
569
+ {
570
+ std::string s{ name} ;
571
+ if (!gbt_force) {
572
572
s.insert (s.begin (), ' !' );
573
573
}
574
574
return s;
@@ -898,45 +898,33 @@ static RPCHelpMan getblocktemplate()
898
898
}
899
899
900
900
UniValue vbavailable (UniValue::VOBJ);
901
- for (int j = 0 ; j < (int )Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++j) {
902
- Consensus::DeploymentPos pos = Consensus::DeploymentPos (j);
903
- ThresholdState state = chainman.m_versionbitscache .State (pindexPrev, consensusParams, pos);
904
- switch (state) {
905
- case ThresholdState::DEFINED:
906
- case ThresholdState::FAILED:
907
- // Not exposed to GBT at all
908
- break ;
909
- case ThresholdState::LOCKED_IN:
910
- // Ensure bit is set in block version
911
- block.nVersion |= chainman.m_versionbitscache .Mask (consensusParams, pos);
912
- [[fallthrough]];
913
- case ThresholdState::STARTED:
914
- {
915
- const struct VBDeploymentInfo & vbinfo = VersionBitsDeploymentInfo[pos];
916
- vbavailable.pushKV (gbt_vb_name (pos), consensusParams.vDeployments [pos].bit );
917
- if (setClientRules.find (vbinfo.name ) == setClientRules.end ()) {
918
- if (!vbinfo.gbt_force ) {
919
- // If the client doesn't support this, don't indicate it in the [default] version
920
- block.nVersion &= ~chainman.m_versionbitscache .Mask (consensusParams, pos);
921
- }
922
- }
923
- break ;
924
- }
925
- case ThresholdState::ACTIVE:
926
- {
927
- // Add to rules only
928
- const struct VBDeploymentInfo & vbinfo = VersionBitsDeploymentInfo[pos];
929
- aRules.push_back (gbt_vb_name (pos));
930
- if (setClientRules.find (vbinfo.name ) == setClientRules.end ()) {
931
- // Not supported by the client; make sure it's safe to proceed
932
- if (!vbinfo.gbt_force ) {
933
- throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" Support for '%s' rule requires explicit client support" , vbinfo.name ));
934
- }
935
- }
936
- break ;
937
- }
901
+ const auto gbtstatus = chainman.m_versionbitscache .GBTStatus (*pindexPrev, consensusParams);
902
+
903
+ for (const auto & [name, info] : gbtstatus.signalling ) {
904
+ vbavailable.pushKV (gbt_force_name (name, info.gbt_force ), info.bit );
905
+ if (!info.gbt_force && !setClientRules.count (name)) {
906
+ // If the client doesn't support this, don't indicate it in the [default] version
907
+ block.nVersion &= ~info.mask ;
938
908
}
939
909
}
910
+
911
+ for (const auto & [name, info] : gbtstatus.locked_in ) {
912
+ block.nVersion |= info.mask ;
913
+ vbavailable.pushKV (gbt_force_name (name, info.gbt_force ), info.bit );
914
+ if (!info.gbt_force && !setClientRules.count (name)) {
915
+ // If the client doesn't support this, don't indicate it in the [default] version
916
+ block.nVersion &= ~info.mask ;
917
+ }
918
+ }
919
+
920
+ for (const auto & [name, info] : gbtstatus.active ) {
921
+ aRules.push_back (gbt_force_name (name, info.gbt_force ));
922
+ if (!info.gbt_force && !setClientRules.count (name)) {
923
+ // Not supported by the client; make sure it's safe to proceed
924
+ throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" Support for '%s' rule requires explicit client support" , name));
925
+ }
926
+ }
927
+
940
928
result.pushKV (" version" , block.nVersion );
941
929
result.pushKV (" rules" , std::move (aRules));
942
930
result.pushKV (" vbavailable" , std::move (vbavailable));
0 commit comments