Skip to content

Commit 14b7cf3

Browse files
committed
refactor: rename CPro*Tx::GetVersion() to GetMaxVersion(), increase use
1 parent 714fb3a commit 14b7cf3

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/evo/providertx.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
bool CProRegTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
1616
{
17-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
17+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
1818
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
1919
}
2020
if (nVersion < ProTxVersion::BasicBLS && nType == MnType::Evo) {
@@ -98,7 +98,7 @@ std::string CProRegTx::ToString() const
9898

9999
bool CProUpServTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
100100
{
101-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
101+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
102102
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
103103
}
104104
if (nVersion < ProTxVersion::BasicBLS && nType == MnType::Evo) {
@@ -124,7 +124,7 @@ std::string CProUpServTx::ToString() const
124124

125125
bool CProUpRegTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
126126
{
127-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
127+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
128128
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
129129
}
130130
if (nMode != 0) {
@@ -157,7 +157,7 @@ std::string CProUpRegTx::ToString() const
157157

158158
bool CProUpRevTx::IsTriviallyValid(bool is_basic_scheme_active, TxValidationState& state) const
159159
{
160-
if (nVersion == 0 || nVersion > GetVersion(is_basic_scheme_active)) {
160+
if (nVersion == 0 || nVersion > GetMaxVersion(is_basic_scheme_active)) {
161161
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-protx-version");
162162
}
163163

src/evo/providertx.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CProRegTx
3131
public:
3232
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_REGISTER;
3333

34-
[[nodiscard]] static constexpr auto GetVersion(const bool is_basic_scheme_active) -> uint16_t
34+
[[nodiscard]] static constexpr uint16_t GetMaxVersion(const bool is_basic_scheme_active)
3535
{
3636
return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS;
3737
}
@@ -57,7 +57,7 @@ class CProRegTx
5757
READWRITE(
5858
obj.nVersion
5959
);
60-
if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS) {
60+
if (obj.nVersion == 0 || obj.nVersion > GetMaxVersion(/*is_basic_scheme_active=*/true)) {
6161
// unknown version, bail out early
6262
return;
6363
}
@@ -125,7 +125,7 @@ class CProUpServTx
125125
public:
126126
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_SERVICE;
127127

128-
[[nodiscard]] static constexpr auto GetVersion(const bool is_basic_scheme_active) -> uint16_t
128+
[[nodiscard]] static constexpr uint16_t GetMaxVersion(const bool is_basic_scheme_active)
129129
{
130130
return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS;
131131
}
@@ -146,7 +146,7 @@ class CProUpServTx
146146
READWRITE(
147147
obj.nVersion
148148
);
149-
if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS) {
149+
if (obj.nVersion == 0 || obj.nVersion > GetMaxVersion(/*is_basic_scheme_active=*/true)) {
150150
// unknown version, bail out early
151151
return;
152152
}
@@ -203,7 +203,7 @@ class CProUpRegTx
203203
public:
204204
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_REGISTRAR;
205205

206-
[[nodiscard]] static constexpr auto GetVersion(const bool is_basic_scheme_active) -> uint16_t
206+
[[nodiscard]] static constexpr uint16_t GetMaxVersion(const bool is_basic_scheme_active)
207207
{
208208
return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS;
209209
}
@@ -222,7 +222,7 @@ class CProUpRegTx
222222
READWRITE(
223223
obj.nVersion
224224
);
225-
if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS) {
225+
if (obj.nVersion == 0 || obj.nVersion > GetMaxVersion(/*is_basic_scheme_active=*/true)) {
226226
// unknown version, bail out early
227227
return;
228228
}
@@ -266,7 +266,7 @@ class CProUpRevTx
266266
public:
267267
static constexpr auto SPECIALTX_TYPE = TRANSACTION_PROVIDER_UPDATE_REVOKE;
268268

269-
[[nodiscard]] static constexpr auto GetVersion(const bool is_basic_scheme_active) -> uint16_t
269+
[[nodiscard]] static constexpr uint16_t GetMaxVersion(const bool is_basic_scheme_active)
270270
{
271271
return is_basic_scheme_active ? ProTxVersion::BasicBLS : ProTxVersion::LegacyBLS;
272272
}
@@ -291,7 +291,7 @@ class CProUpRevTx
291291
READWRITE(
292292
obj.nVersion
293293
);
294-
if (obj.nVersion == 0 || obj.nVersion > ProTxVersion::BasicBLS) {
294+
if (obj.nVersion == 0 || obj.nVersion > GetMaxVersion(/*is_basic_scheme_active=*/true)) {
295295
// unknown version, bail out early
296296
return;
297297
}

src/rpc/evo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request,
689689

690690
ptx.keyIDOwner = ParsePubKeyIDFromAddress(request.params[paramIdx + 1].get_str(), "owner address");
691691
ptx.pubKeyOperator.Set(ParseBLSPubKey(request.params[paramIdx + 2].get_str(), "operator BLS address", use_legacy), use_legacy);
692-
ptx.nVersion = use_legacy ? ProTxVersion::LegacyBLS : ProTxVersion::BasicBLS;
692+
ptx.nVersion = CProRegTx::GetMaxVersion(/*is_basic_scheme_active=*/!use_legacy);
693693
CHECK_NONFATAL(ptx.pubKeyOperator.IsLegacy() == (ptx.nVersion == ProTxVersion::LegacyBLS));
694694

695695
CKeyID keyIDVoting = ptx.keyIDOwner;
@@ -1111,7 +1111,7 @@ static RPCHelpMan protx_update_registrar_wrapper(const bool specific_legacy_bls_
11111111
ptx.pubKeyOperator = dmn->pdmnState->pubKeyOperator;
11121112
}
11131113

1114-
ptx.nVersion = use_legacy ? ProTxVersion::LegacyBLS : ProTxVersion::BasicBLS;
1114+
ptx.nVersion = CProUpRegTx::GetMaxVersion(/*is_basic_scheme_active=*/!use_legacy);
11151115
CHECK_NONFATAL(ptx.pubKeyOperator.IsLegacy() == (ptx.nVersion == ProTxVersion::LegacyBLS));
11161116

11171117
if (request.params[2].get_str() != "") {
@@ -1204,7 +1204,7 @@ static RPCHelpMan protx_revoke()
12041204

12051205
const bool isV19active{DeploymentActiveAfter(WITH_LOCK(cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
12061206
CProUpRevTx ptx;
1207-
ptx.nVersion = CProUpRevTx::GetVersion(isV19active);
1207+
ptx.nVersion = CProUpRevTx::GetMaxVersion(/*is_basic_scheme_active=*/isV19active);
12081208
ptx.proTxHash = ParseHashV(request.params[0], "proTxHash");
12091209

12101210
CBLSSecretKey keyOperator = ParseBLSSecretKey(request.params[1].get_str(), "operatorKey");

src/test/block_reward_reallocation_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static CMutableTransaction CreateProRegTx(const CChain& active_chain, const CTxM
114114
operatorKeyRet.MakeNewKey();
115115

116116
CProRegTx proTx;
117-
proTx.nVersion = CProRegTx::GetVersion(!bls::bls_legacy_scheme);
117+
proTx.nVersion = CProRegTx::GetMaxVersion(!bls::bls_legacy_scheme);
118118
proTx.collateralOutpoint.n = 0;
119119
proTx.addr = LookupNumeric("1.1.1.1", port);
120120
proTx.keyIDOwner = ownerKeyRet.GetPubKey().GetID();

src/test/evo_deterministicmns_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static CMutableTransaction CreateProRegTx(const CChain& active_chain, const CTxM
103103
operatorKeyRet.MakeNewKey();
104104

105105
CProRegTx proTx;
106-
proTx.nVersion = CProRegTx::GetVersion(!bls::bls_legacy_scheme);
106+
proTx.nVersion = CProRegTx::GetMaxVersion(!bls::bls_legacy_scheme);
107107
proTx.collateralOutpoint.n = 0;
108108
proTx.addr = LookupNumeric("1.1.1.1", port);
109109
proTx.keyIDOwner = ownerKeyRet.GetPubKey().GetID();
@@ -125,7 +125,7 @@ static CMutableTransaction CreateProRegTx(const CChain& active_chain, const CTxM
125125
static CMutableTransaction CreateProUpServTx(const CChain& active_chain, const CTxMemPool& mempool, SimpleUTXOMap& utxos, const uint256& proTxHash, const CBLSSecretKey& operatorKey, int port, const CScript& scriptOperatorPayout, const CKey& coinbaseKey)
126126
{
127127
CProUpServTx proTx;
128-
proTx.nVersion = CProUpRevTx::GetVersion(!bls::bls_legacy_scheme);
128+
proTx.nVersion = CProUpServTx::GetMaxVersion(!bls::bls_legacy_scheme);
129129
proTx.proTxHash = proTxHash;
130130
proTx.addr = LookupNumeric("1.1.1.1", port);
131131
proTx.scriptOperatorPayout = scriptOperatorPayout;
@@ -145,7 +145,7 @@ static CMutableTransaction CreateProUpServTx(const CChain& active_chain, const C
145145
static CMutableTransaction CreateProUpRegTx(const CChain& active_chain, const CTxMemPool& mempool, SimpleUTXOMap& utxos, const uint256& proTxHash, const CKey& mnKey, const CBLSPublicKey& pubKeyOperator, const CKeyID& keyIDVoting, const CScript& scriptPayout, const CKey& coinbaseKey)
146146
{
147147
CProUpRegTx proTx;
148-
proTx.nVersion = CProUpRegTx::GetVersion(!bls::bls_legacy_scheme);
148+
proTx.nVersion = CProUpRegTx::GetMaxVersion(!bls::bls_legacy_scheme);
149149
proTx.proTxHash = proTxHash;
150150
proTx.pubKeyOperator.Set(pubKeyOperator, bls::bls_legacy_scheme.load());
151151
proTx.keyIDVoting = keyIDVoting;
@@ -166,7 +166,7 @@ static CMutableTransaction CreateProUpRegTx(const CChain& active_chain, const CT
166166
static CMutableTransaction CreateProUpRevTx(const CChain& active_chain, const CTxMemPool& mempool, SimpleUTXOMap& utxos, const uint256& proTxHash, const CBLSSecretKey& operatorKey, const CKey& coinbaseKey)
167167
{
168168
CProUpRevTx proTx;
169-
proTx.nVersion = CProUpRevTx::GetVersion(!bls::bls_legacy_scheme);
169+
proTx.nVersion = CProUpRevTx::GetMaxVersion(!bls::bls_legacy_scheme);
170170
proTx.proTxHash = proTxHash;
171171

172172
CMutableTransaction tx;
@@ -632,7 +632,7 @@ void FuncTestMempoolReorg(TestChainSetup& setup)
632632
BOOST_CHECK_EQUAL(block->GetHash(), chainman.ActiveChain().Tip()->GetBlockHash());
633633

634634
CProRegTx payload;
635-
payload.nVersion = CProRegTx::GetVersion(!bls::bls_legacy_scheme);
635+
payload.nVersion = CProRegTx::GetMaxVersion(!bls::bls_legacy_scheme);
636636
payload.addr = LookupNumeric("1.1.1.1", 1);
637637
payload.keyIDOwner = ownerKey.GetPubKey().GetID();
638638
payload.pubKeyOperator.Set(operatorKey.GetPublicKey(), bls::bls_legacy_scheme.load());
@@ -774,7 +774,7 @@ void FuncVerifyDB(TestChainSetup& setup)
774774
BOOST_CHECK_EQUAL(block->GetHash(), chainman.ActiveChain().Tip()->GetBlockHash());
775775

776776
CProRegTx payload;
777-
payload.nVersion = CProRegTx::GetVersion(!bls::bls_legacy_scheme);
777+
payload.nVersion = CProRegTx::GetMaxVersion(!bls::bls_legacy_scheme);
778778
payload.addr = LookupNumeric("1.1.1.1", 1);
779779
payload.keyIDOwner = ownerKey.GetPubKey().GetID();
780780
payload.pubKeyOperator.Set(operatorKey.GetPublicKey(), bls::bls_legacy_scheme.load());

0 commit comments

Comments
 (0)