Skip to content

Commit 5c58fbd

Browse files
UdjinM6knst
authored andcommitted
fix: preserve the original order of fields in CDeterministicMNStateDiff
5021 follow-up
1 parent 42b60e1 commit 5c58fbd

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/evo/dmnstate.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class CDeterministicMNStateDiff
149149
Field_scriptOperatorPayout = 0x2000,
150150
};
151151

152-
#define DMN_STATE_DIFF_ALL_FIELDS_BUT_PUBKEY \
152+
#define DMN_STATE_DIFF_ALL_FIELDS \
153153
DMN_STATE_DIFF_LINE(nRegisteredHeight) \
154154
DMN_STATE_DIFF_LINE(nLastPaidHeight) \
155155
DMN_STATE_DIFF_LINE(nPoSePenalty) \
@@ -159,15 +159,12 @@ class CDeterministicMNStateDiff
159159
DMN_STATE_DIFF_LINE(confirmedHash) \
160160
DMN_STATE_DIFF_LINE(confirmedHashWithProRegTxHash) \
161161
DMN_STATE_DIFF_LINE(keyIDOwner) \
162+
DMN_STATE_DIFF_LINE(pubKeyOperator) \
162163
DMN_STATE_DIFF_LINE(keyIDVoting) \
163164
DMN_STATE_DIFF_LINE(addr) \
164165
DMN_STATE_DIFF_LINE(scriptPayout) \
165166
DMN_STATE_DIFF_LINE(scriptOperatorPayout)
166167

167-
#define DMN_STATE_DIFF_ALL_FIELDS \
168-
DMN_STATE_DIFF_ALL_FIELDS_BUT_PUBKEY \
169-
DMN_STATE_DIFF_LINE(pubKeyOperator) \
170-
171168
public:
172169
uint32_t fields{0};
173170
// we reuse the state class, but only the members as noted by fields are valid
@@ -185,13 +182,14 @@ class CDeterministicMNStateDiff
185182
SERIALIZE_METHODS(CDeterministicMNStateDiff, obj)
186183
{
187184
READWRITE(VARINT(obj.fields));
188-
#define DMN_STATE_DIFF_LINE(f) if (obj.fields & Field_##f) READWRITE(obj.state.f);
189-
DMN_STATE_DIFF_ALL_FIELDS_BUT_PUBKEY
185+
#define DMN_STATE_DIFF_LINE(f) \
186+
if (obj.fields & Field_pubKeyOperator) {\
187+
/* TODO: implement migration to Basic BLS after the fork */ \
188+
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.state.pubKeyOperator), true)); \
189+
} else if (obj.fields & Field_##f) READWRITE(obj.state.f);
190+
191+
DMN_STATE_DIFF_ALL_FIELDS
190192
#undef DMN_STATE_DIFF_LINE
191-
if (obj.fields & Field_pubKeyOperator) {
192-
// TODO: implement migration to Basic BLS after the fork
193-
READWRITE(CBLSLazyPublicKeyVersionWrapper(const_cast<CBLSLazyPublicKey&>(obj.state.pubKeyOperator), true));
194-
}
195193
}
196194

197195
void ApplyToState(CDeterministicMNState& target) const

0 commit comments

Comments
 (0)