Skip to content

Commit 50941ab

Browse files
committed
Refactor: Remove redundant trailing commas, reorder imports, and improve error handling formatting across modules
1 parent 4b07f59 commit 50941ab

File tree

10 files changed

+66
-59
lines changed

10 files changed

+66
-59
lines changed

common/src/queries/accounts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub enum AccountsStateQueryResponse {
8181
// DReps-related responses
8282
DrepDelegators(DrepDelegators),
8383
AccountsDrepDelegationsMap(HashMap<StakeAddress, Option<DRepChoice>>),
84-
8584
Error(QueryError),
8685
}
8786

common/src/queries/addresses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ pub enum AddressStateQueryResponse {
1616
AddressTotals(AddressTotals),
1717
AddressUTxOs(Vec<UTxOIdentifier>),
1818
AddressTransactions(Vec<TxIdentifier>),
19-
Error(QueryError)
19+
Error(QueryError),
2020
}

common/src/queries/blocks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ pub enum BlocksStateQueryResponse {
9191
BlockInvolvedAddresses(BlockInvolvedAddresses),
9292
BlockHashes(BlockHashes),
9393
TransactionHashes(TransactionHashes),
94-
9594
Error(QueryError),
9695
}
9796

common/src/queries/epochs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub enum EpochsStateQueryResponse {
2424
EpochStakeDistribution(EpochStakeDistribution),
2525
EpochStakeDistributionByPool(EpochStakeDistributionByPool),
2626
LatestEpochBlocksMintedByPool(u64),
27-
2827
Error(QueryError),
2928
}
3029

common/src/queries/parameters.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub enum ParametersStateQueryResponse {
1616
LatestEpochParameters(ProtocolParams),
1717
EpochParameters(ProtocolParams),
1818
NetworkName(String),
19-
2019
Error(QueryError),
2120
}
2221

common/src/queries/spdd.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ pub enum SPDDStateQuery {
1010
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
1111
pub enum SPDDStateQueryResponse {
1212
EpochTotalActiveStakes(u64),
13-
1413
Error(QueryError),
1514
}

modules/accounts_state/src/accounts_state.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -567,27 +567,27 @@ impl AccountsState {
567567
AccountsStateQuery::GetAccountsUtxoValuesMap { stake_addresses } => {
568568
match state.get_accounts_utxo_values_map(stake_addresses) {
569569
Some(map) => AccountsStateQueryResponse::AccountsUtxoValuesMap(map),
570-
None => AccountsStateQueryResponse::Error(
571-
QueryError::not_found("One or more accounts not found"),
572-
),
570+
None => AccountsStateQueryResponse::Error(QueryError::not_found(
571+
"One or more accounts not found",
572+
)),
573573
}
574574
}
575575

576576
AccountsStateQuery::GetAccountsUtxoValuesSum { stake_addresses } => {
577577
match state.get_accounts_utxo_values_sum(stake_addresses) {
578578
Some(sum) => AccountsStateQueryResponse::AccountsUtxoValuesSum(sum),
579-
None => AccountsStateQueryResponse::Error(
580-
QueryError::not_found("One or more accounts not found"),
581-
),
579+
None => AccountsStateQueryResponse::Error(QueryError::not_found(
580+
"One or more accounts not found",
581+
)),
582582
}
583583
}
584584

585585
AccountsStateQuery::GetAccountsBalancesMap { stake_addresses } => {
586586
match state.get_accounts_balances_map(stake_addresses) {
587587
Some(map) => AccountsStateQueryResponse::AccountsBalancesMap(map),
588-
None => AccountsStateQueryResponse::Error(
589-
QueryError::not_found("One or more accounts not found"),
590-
),
588+
None => AccountsStateQueryResponse::Error(QueryError::not_found(
589+
"One or more accounts not found",
590+
)),
591591
}
592592
}
593593

@@ -600,18 +600,18 @@ impl AccountsState {
600600
AccountsStateQuery::GetAccountsBalancesSum { stake_addresses } => {
601601
match state.get_account_balances_sum(stake_addresses) {
602602
Some(sum) => AccountsStateQueryResponse::AccountsBalancesSum(sum),
603-
None => AccountsStateQueryResponse::Error(
604-
QueryError::not_found("One or more accounts not found"),
605-
),
603+
None => AccountsStateQueryResponse::Error(QueryError::not_found(
604+
"One or more accounts not found",
605+
)),
606606
}
607607
}
608608

609609
AccountsStateQuery::GetSPDDByEpoch { epoch } => match spdd_store_guard {
610610
Some(spdd_store) => match spdd_store.query_by_epoch(*epoch) {
611611
Ok(result) => AccountsStateQueryResponse::SPDDByEpoch(result),
612-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
613-
e.to_string(),
614-
)),
612+
Err(e) => AccountsStateQueryResponse::Error(
613+
QueryError::internal_error(e.to_string()),
614+
),
615615
},
616616
None => {
617617
AccountsStateQueryResponse::Error(QueryError::storage_disabled("SPDD"))

modules/address_state/src/address_state.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
55
use std::sync::Arc;
66

7+
use crate::{
8+
immutable_address_store::ImmutableAddressStore,
9+
state::{AddressStorageConfig, State},
10+
};
11+
use acropolis_common::queries::errors::QueryError;
712
use acropolis_common::{
813
messages::{CardanoMessage, Message, StateQuery, StateQueryResponse},
914
queries::addresses::{
@@ -16,11 +21,6 @@ use caryatid_sdk::{module, Context, Module, Subscription};
1621
use config::Config;
1722
use tokio::sync::{mpsc, Mutex};
1823
use tracing::{error, info};
19-
use acropolis_common::queries::errors::QueryError;
20-
use crate::{
21-
immutable_address_store::ImmutableAddressStore,
22-
state::{AddressStorageConfig, State},
23-
};
2424
mod immutable_address_store;
2525
mod state;
2626
mod volatile_addresses;

modules/drep_state/src/drep_state.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ impl DRepState {
325325
QueryError::internal_error(msg),
326326
),
327327
},
328-
None => GovernanceStateQueryResponse::Error(QueryError::internal_error(
329-
"No current state",
330-
)),
328+
None => GovernanceStateQueryResponse::Error(
329+
QueryError::internal_error("No current state"),
330+
),
331331
}
332332
}
333333
GovernanceStateQuery::GetDRepDelegators { drep_credential } => {
@@ -349,9 +349,9 @@ impl DRepState {
349349
QueryError::internal_error(msg),
350350
),
351351
},
352-
None => GovernanceStateQueryResponse::Error(QueryError::internal_error(
353-
"No current state",
354-
)),
352+
None => GovernanceStateQueryResponse::Error(
353+
QueryError::internal_error("No current state"),
354+
),
355355
}
356356
}
357357
GovernanceStateQuery::GetDRepMetadata { drep_credential } => {
@@ -369,9 +369,9 @@ impl DRepState {
369369
QueryError::internal_error(msg),
370370
),
371371
},
372-
None => GovernanceStateQueryResponse::Error(QueryError::internal_error(
373-
"No current state",
374-
)),
372+
None => GovernanceStateQueryResponse::Error(
373+
QueryError::internal_error("No current state"),
374+
),
375375
}
376376
}
377377

@@ -392,9 +392,9 @@ impl DRepState {
392392
QueryError::internal_error(msg),
393393
),
394394
},
395-
None => GovernanceStateQueryResponse::Error(QueryError::internal_error(
396-
"No current state",
397-
)),
395+
None => GovernanceStateQueryResponse::Error(
396+
QueryError::internal_error("No current state"),
397+
),
398398
}
399399
}
400400
GovernanceStateQuery::GetDRepVotes { drep_credential } => {
@@ -414,9 +414,9 @@ impl DRepState {
414414
QueryError::internal_error(msg),
415415
),
416416
},
417-
None => GovernanceStateQueryResponse::Error(QueryError::internal_error(
418-
"No current state",
419-
)),
417+
None => GovernanceStateQueryResponse::Error(
418+
QueryError::internal_error("No current state"),
419+
),
420420
}
421421
}
422422
_ => GovernanceStateQueryResponse::Error(QueryError::invalid_request(format!(

modules/historical_accounts_state/src/historical_accounts_state.rs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,11 @@ impl HistoricalAccountsState {
319319
Ok(None) => AccountsStateQueryResponse::Error(QueryError::not_found(
320320
format!("Account {}", account),
321321
)),
322-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
323-
format!("Failed to get registration history: {}", e),
324-
)),
322+
Err(e) => {
323+
AccountsStateQueryResponse::Error(QueryError::internal_error(
324+
format!("Failed to get registration history: {}", e),
325+
))
326+
}
325327
}
326328
}
327329
AccountsStateQuery::GetAccountDelegationHistory { account } => {
@@ -332,9 +334,11 @@ impl HistoricalAccountsState {
332334
Ok(None) => AccountsStateQueryResponse::Error(QueryError::not_found(
333335
format!("Account {}", account),
334336
)),
335-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
336-
format!("Failed to get delegation history: {}", e),
337-
)),
337+
Err(e) => {
338+
AccountsStateQueryResponse::Error(QueryError::internal_error(
339+
format!("Failed to get delegation history: {}", e),
340+
))
341+
}
338342
}
339343
}
340344
AccountsStateQuery::GetAccountMIRHistory { account } => {
@@ -343,9 +347,11 @@ impl HistoricalAccountsState {
343347
Ok(None) => AccountsStateQueryResponse::Error(QueryError::not_found(
344348
format!("Account {}", account),
345349
)),
346-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
347-
format!("Failed to get MIR history: {}", e),
348-
)),
350+
Err(e) => {
351+
AccountsStateQueryResponse::Error(QueryError::internal_error(
352+
format!("Failed to get MIR history: {}", e),
353+
))
354+
}
349355
}
350356
}
351357
AccountsStateQuery::GetAccountWithdrawalHistory { account } => {
@@ -356,9 +362,11 @@ impl HistoricalAccountsState {
356362
Ok(None) => AccountsStateQueryResponse::Error(QueryError::not_found(
357363
format!("Account {}", account),
358364
)),
359-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
360-
format!("Failed to get withdrawal history: {}", e),
361-
)),
365+
Err(e) => {
366+
AccountsStateQueryResponse::Error(QueryError::internal_error(
367+
format!("Failed to get withdrawal history: {}", e),
368+
))
369+
}
362370
}
363371
}
364372
AccountsStateQuery::GetAccountRewardHistory { account } => {
@@ -369,9 +377,11 @@ impl HistoricalAccountsState {
369377
Ok(None) => AccountsStateQueryResponse::Error(QueryError::not_found(
370378
format!("Account {}", account),
371379
)),
372-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
373-
format!("Failed to get reward history: {}", e),
374-
)),
380+
Err(e) => {
381+
AccountsStateQueryResponse::Error(QueryError::internal_error(
382+
format!("Failed to get reward history: {}", e),
383+
))
384+
}
375385
}
376386
}
377387
AccountsStateQuery::GetAccountAssociatedAddresses { account } => {
@@ -382,9 +392,11 @@ impl HistoricalAccountsState {
382392
Ok(None) => AccountsStateQueryResponse::Error(QueryError::not_found(
383393
format!("Account {}", account),
384394
)),
385-
Err(e) => AccountsStateQueryResponse::Error(QueryError::internal_error(
386-
format!("Failed to get associated addresses: {}", e),
387-
)),
395+
Err(e) => {
396+
AccountsStateQueryResponse::Error(QueryError::internal_error(
397+
format!("Failed to get associated addresses: {}", e),
398+
))
399+
}
388400
}
389401
}
390402
_ => AccountsStateQueryResponse::Error(QueryError::not_implemented(format!(

0 commit comments

Comments
 (0)