Skip to content

Commit 97c6d3c

Browse files
authored
Merge pull request #282 from input-output-hk/sg/address-state-clippy
chore: use clippy on address_state
2 parents 8e2da8b + 2d7cd68 commit 97c6d3c

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

.github/workflows/run-tests-on-push-to-main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
cargo clippy \
2929
--package acropolis_common \
3030
--package acropolis_codec \
31+
--package acropolis_module_address_state \
3132
--package acropolis_module_assets_state \
3233
--package acropolis_module_block_unpacker \
3334
--package acropolis_module_chain_store \

modules/address_state/src/address_state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl AddressState {
9090
if let Message::Cardano((ref block_info, CardanoMessage::ProtocolParams(params))) =
9191
message.as_ref()
9292
{
93-
Self::check_sync(&current_block, &block_info, "params");
93+
Self::check_sync(&current_block, block_info, "params");
9494
let mut state = state_mutex.lock().await;
9595
state.volatile.start_new_epoch(block_info.number);
9696
if let Some(shelley) = &params.params.shelley {
@@ -209,21 +209,21 @@ impl AddressState {
209209
let state = state_mutex.lock().await;
210210
let response = match query {
211211
AddressStateQuery::GetAddressUTxOs { address } => {
212-
match state.get_address_utxos(&address).await {
212+
match state.get_address_utxos(address).await {
213213
Ok(Some(utxos)) => AddressStateQueryResponse::AddressUTxOs(utxos),
214214
Ok(None) => AddressStateQueryResponse::NotFound,
215215
Err(e) => AddressStateQueryResponse::Error(e.to_string()),
216216
}
217217
}
218218
AddressStateQuery::GetAddressTransactions { address } => {
219-
match state.get_address_transactions(&address).await {
219+
match state.get_address_transactions(address).await {
220220
Ok(Some(txs)) => AddressStateQueryResponse::AddressTransactions(txs),
221221
Ok(None) => AddressStateQueryResponse::NotFound,
222222
Err(e) => AddressStateQueryResponse::Error(e.to_string()),
223223
}
224224
}
225225
AddressStateQuery::GetAddressTotals { address } => {
226-
match state.get_address_totals(&address).await {
226+
match state.get_address_totals(address).await {
227227
Ok(totals) => AddressStateQueryResponse::AddressTotals(totals),
228228
Err(e) => AddressStateQueryResponse::Error(e.to_string()),
229229
}

modules/address_state/src/immutable_address_store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,17 @@ impl ImmutableAddressStore {
139139
batch.insert(
140140
&self.utxos,
141141
ADDRESS_UTXOS_EPOCH_COUNTER,
142-
&epoch.to_le_bytes(),
142+
epoch.to_le_bytes(),
143143
);
144144
}
145145
if persist_txs {
146-
batch.insert(&self.txs, ADDRESS_TXS_EPOCH_COUNTER, &epoch.to_le_bytes());
146+
batch.insert(&self.txs, ADDRESS_TXS_EPOCH_COUNTER, epoch.to_le_bytes());
147147
}
148148
if persist_totals {
149149
batch.insert(
150150
&self.totals,
151151
ADDRESS_TOTALS_EPOCH_COUNTER,
152-
&epoch.to_le_bytes(),
152+
epoch.to_le_bytes(),
153153
);
154154
}
155155

modules/address_state/src/state.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ impl State {
121121

122122
let store = self.immutable.clone();
123123

124-
let mut combined: Vec<TxIdentifier> = match store.get_txs(address).await? {
125-
Some(db) => db,
126-
None => Vec::new(),
127-
};
124+
let mut combined: Vec<TxIdentifier> = store.get_txs(address).await?.unwrap_or_default();
128125

129126
for map in self.volatile.window.iter() {
130127
if let Some(entry) = map.get(address) {
@@ -148,10 +145,7 @@ impl State {
148145

149146
let store = self.immutable.clone();
150147

151-
let mut totals = match store.get_totals(address).await? {
152-
Some(db) => db,
153-
None => AddressTotals::default(),
154-
};
148+
let mut totals = store.get_totals(address).await?.unwrap_or_default();
155149

156150
for map in self.volatile.window.iter() {
157151
if let Some(entry) = map.get(address) {

0 commit comments

Comments
 (0)