Skip to content

Commit a3dd388

Browse files
committed
Use as_ref in immutable_historical_account_store.rs vs into_inner()
1 parent 2f61e83 commit a3dd388

File tree

6 files changed

+34
-25
lines changed

6 files changed

+34
-25
lines changed

common/src/hash.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ impl<const BYTES: usize> Hash<BYTES> {
5353
pub fn into_inner(self) -> [u8; BYTES] {
5454
self.0
5555
}
56+
57+
#[inline]
58+
pub fn as_inner(&self) -> &[u8; BYTES] {
59+
&self.0
60+
}
5661
}
5762

5863
impl<const BYTES: usize> From<[u8; BYTES]> for Hash<BYTES> {

common/src/snapshot/streaming_snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'b, C> minicbor::Decode<'b, C> for Account {
309309

310310
pub use crate::types::AddrKeyhash;
311311
pub use crate::types::ScriptHash;
312-
use crate::{PoolId};
312+
use crate::PoolId;
313313
/// Alias minicbor as cbor for pool_params module
314314
pub use minicbor as cbor;
315315

common/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ declare_hash_type!(BlockHash, 32);
451451
declare_hash_type!(TxHash, 32);
452452
declare_hash_type_with_bech32!(VrfKeyHash, 32, "vrf_vk");
453453
declare_hash_type_with_bech32!(PoolId, 28, "pool");
454-
declare_hash_type_with_bech32!(DrepKey, 28, "drep");
455-
declare_hash_type_with_bech32!(DrepScriptKey, 28, "drep_script");
454+
// declare_hash_type_with_bech32!(DrepKey, 28, "drep");
455+
// declare_hash_type_with_bech32!(DrepScriptKey, 28, "drep_script");
456456

457457
/// Data hash used for metadata, anchors (SHA256)
458458
pub type DataHash = Vec<u8>;

modules/accounts_state/src/verifier.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,11 @@ impl Verifier {
167167
continue;
168168
};
169169

170-
expected_rewards.entry(spo.try_into().unwrap()).or_default().push(
171-
RewardDetail {
172-
account: stake_address,
173-
rtype,
174-
amount,
175-
},
176-
);
170+
expected_rewards.entry(spo.try_into().unwrap()).or_default().push(RewardDetail {
171+
account: stake_address,
172+
rtype,
173+
amount,
174+
});
177175
}
178176

179177
info!(

modules/historical_accounts_state/src/immutable_historical_account_store.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ impl ImmutableHistoricalAccountStore {
156156
&self,
157157
account: &StakeAddress,
158158
) -> Result<Option<Vec<RewardHistory>>> {
159-
let mut immutable_rewards =
160-
self.collect_partition::<RewardHistory>(&self.rewards_history, account.get_hash())?;
159+
let mut immutable_rewards = self.collect_partition::<RewardHistory>(
160+
&self.rewards_history,
161+
account.get_hash().as_ref(),
162+
)?;
161163

162164
self.merge_pending(
163165
account,
@@ -175,7 +177,7 @@ impl ImmutableHistoricalAccountStore {
175177
) -> Result<Option<Vec<ActiveStakeHistory>>> {
176178
let mut immutable_active_stake = self.collect_partition::<ActiveStakeHistory>(
177179
&self.active_stake_history,
178-
account.get_hash(),
180+
account.get_hash().as_ref(),
179181
)?;
180182

181183
self.merge_pending(
@@ -194,7 +196,7 @@ impl ImmutableHistoricalAccountStore {
194196
) -> Result<Option<Vec<RegistrationUpdate>>> {
195197
let mut immutable_registrations = self.collect_partition::<RegistrationUpdate>(
196198
&self.registration_history,
197-
account.get_hash(),
199+
account.get_hash().as_ref(),
198200
)?;
199201

200202
self.merge_pending(
@@ -211,8 +213,10 @@ impl ImmutableHistoricalAccountStore {
211213
&self,
212214
account: &StakeAddress,
213215
) -> Result<Option<Vec<DelegationUpdate>>> {
214-
let mut immutable_delegations = self
215-
.collect_partition::<DelegationUpdate>(&self.delegation_history, account.get_hash())?;
216+
let mut immutable_delegations = self.collect_partition::<DelegationUpdate>(
217+
&self.delegation_history,
218+
account.get_hash().as_ref(),
219+
)?;
216220

217221
self.merge_pending(
218222
account,
@@ -228,8 +232,10 @@ impl ImmutableHistoricalAccountStore {
228232
&self,
229233
account: &StakeAddress,
230234
) -> Result<Option<Vec<AccountWithdrawal>>> {
231-
let mut immutable_mirs =
232-
self.collect_partition::<AccountWithdrawal>(&self.mir_history, account.get_hash())?;
235+
let mut immutable_mirs = self.collect_partition::<AccountWithdrawal>(
236+
&self.mir_history,
237+
account.get_hash().as_ref(),
238+
)?;
233239

234240
self.merge_pending(account, |e| e.mir_history.as_ref(), &mut immutable_mirs).await;
235241

@@ -240,8 +246,10 @@ impl ImmutableHistoricalAccountStore {
240246
&self,
241247
account: &StakeAddress,
242248
) -> Result<Option<Vec<AccountWithdrawal>>> {
243-
let mut immutable_withdrawals = self
244-
.collect_partition::<AccountWithdrawal>(&self.withdrawal_history, account.get_hash())?;
249+
let mut immutable_withdrawals = self.collect_partition::<AccountWithdrawal>(
250+
&self.withdrawal_history,
251+
account.get_hash().as_ref(),
252+
)?;
245253

246254
self.merge_pending(
247255
account,
@@ -258,7 +266,7 @@ impl ImmutableHistoricalAccountStore {
258266
account: &StakeAddress,
259267
) -> Result<Option<Vec<ShelleyAddress>>> {
260268
let mut immutable_addresses =
261-
self.collect_partition::<ShelleyAddress>(&self.addresses, account.get_hash())?;
269+
self.collect_partition::<ShelleyAddress>(&self.addresses, account.get_hash().as_ref())?;
262270

263271
self.merge_pending(account, |e| e.addresses.as_ref(), &mut immutable_addresses).await;
264272

@@ -321,7 +329,7 @@ impl ImmutableHistoricalAccountStore {
321329

322330
fn make_epoch_key(account: &StakeAddress, epoch: u32) -> [u8; 32] {
323331
let mut key = [0u8; 32];
324-
key[..28].copy_from_slice(&account.get_credential().get_hash());
332+
key[..28].copy_from_slice(&account.get_credential().get_hash().as_ref());
325333
key[28..32].copy_from_slice(&epoch.to_be_bytes());
326334
key
327335
}

modules/parameters_state/src/genesis_params.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ fn map_drep_thresholds(thresholds: &conway::DRepVotingThresholds) -> Result<DRep
107107
pub fn map_constitution(constitution: &conway::Constitution) -> Result<Constitution> {
108108
Ok(Constitution {
109109
anchor: map_anchor(&constitution.anchor)?,
110-
guardrail_script: Some(
111-
decode_hex_string(&constitution.script, 28)?.try_into().unwrap(),
112-
),
110+
guardrail_script: Some(decode_hex_string(&constitution.script, 28)?.try_into().unwrap()),
113111
})
114112
}
115113

0 commit comments

Comments
 (0)