Skip to content

Commit c09a81d

Browse files
committed
fix typo and add RegistrationStatus enum
Signed-off-by: William Hankins <william@sundae.fi>
1 parent 381c7ff commit c09a81d

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

common/src/queries/accounts.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,17 @@ pub struct RegistrationUpdate {
118118
#[n(0)]
119119
pub tx_identifier: TxIdentifier,
120120
#[n(1)]
121-
pub deregistered: bool,
121+
pub status: RegistrationStatus,
122+
}
123+
124+
#[derive(
125+
Debug, Clone, serde::Serialize, serde::Deserialize, minicbor::Decode, minicbor::Encode,
126+
)]
127+
pub enum RegistrationStatus {
128+
#[n(0)]
129+
Registered,
130+
#[n(1)]
131+
Deregistered,
122132
}
123133

124134
#[derive(

modules/historical_accounts_state/src/immutable_historical_account_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ impl ImmutableHistoricalAccountStore {
270270
block_deltas: Vec<HashMap<StakeAddress, AccountEntry>>,
271271
) -> HashMap<StakeAddress, AccountEntry> {
272272
block_deltas.into_par_iter().reduce(HashMap::new, |mut acc, block_map| {
273-
for (accont, entry) in block_map {
274-
let agg_entry = acc.entry(accont).or_default();
273+
for (account, entry) in block_map {
274+
let agg_entry = acc.entry(account).or_default();
275275

276276
Self::extend_opt_vec(&mut agg_entry.reward_history, entry.reward_history);
277277
Self::extend_opt_vec(

modules/historical_accounts_state/src/state.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use acropolis_common::{
77
messages::{
88
AddressDeltasMessage, StakeRewardDeltasMessage, TxCertificatesMessage, WithdrawalsMessage,
99
},
10-
queries::accounts::{AccountWithdrawal, DelegationUpdate, RegistrationUpdate},
10+
queries::accounts::{
11+
AccountWithdrawal, DelegationUpdate, RegistrationStatus, RegistrationUpdate,
12+
},
1113
BlockInfo, InstantaneousRewardTarget, PoolId, ShelleyAddress, StakeAddress, StakeCredential,
1214
TxCertificate, TxIdentifier,
1315
};
@@ -131,14 +133,14 @@ impl State {
131133
self.handle_stake_registration_change(
132134
&sc.stake_address,
133135
&sc.tx_identifier,
134-
false,
136+
RegistrationStatus::Registered,
135137
);
136138
}
137139
TxCertificate::StakeDeregistration(sc) => {
138140
self.handle_stake_registration_change(
139141
&sc.stake_address,
140142
&sc.tx_identifier,
141-
true,
143+
RegistrationStatus::Deregistered,
142144
);
143145
}
144146

@@ -147,14 +149,14 @@ impl State {
147149
self.handle_stake_registration_change(
148150
&reg.cert.stake_address,
149151
&reg.tx_identifier,
150-
false,
152+
RegistrationStatus::Registered,
151153
);
152154
}
153155
TxCertificate::Deregistration(dreg) => {
154156
self.handle_stake_registration_change(
155157
&dreg.cert.stake_address,
156158
&dreg.tx_identifier,
157-
true,
159+
RegistrationStatus::Deregistered,
158160
);
159161
}
160162

@@ -163,7 +165,7 @@ impl State {
163165
self.handle_stake_registration_change(
164166
&delegation.cert.stake_address,
165167
&delegation.tx_identifier,
166-
false,
168+
RegistrationStatus::Registered,
167169
);
168170
self.handle_stake_delegation(
169171
&delegation.cert.stake_address,
@@ -176,7 +178,7 @@ impl State {
176178
self.handle_stake_registration_change(
177179
&delegation.cert.stake_address,
178180
&delegation.tx_identifier,
179-
false,
181+
RegistrationStatus::Registered,
180182
);
181183
self.handle_stake_delegation(
182184
&delegation.cert.stake_address,
@@ -207,7 +209,7 @@ impl State {
207209
self.handle_stake_registration_change(
208210
&delegation.cert.stake_address,
209211
&delegation.tx_identifier,
210-
false,
212+
RegistrationStatus::Registered,
211213
);
212214
}
213215

@@ -299,13 +301,13 @@ impl State {
299301
&mut self,
300302
account: &StakeAddress,
301303
tx_identifier: &TxIdentifier,
302-
deregistered: bool,
304+
status: RegistrationStatus,
303305
) {
304306
let volatile = self.volatile.window.back_mut().expect("window should never be empty");
305307
let entry = volatile.entry(account.clone()).or_default();
306308
let update = RegistrationUpdate {
307309
tx_identifier: *tx_identifier,
308-
deregistered,
310+
status,
309311
};
310312
entry.registration_history.get_or_insert_with(Vec::new).push(update);
311313
}

0 commit comments

Comments
 (0)