From 60f1a53bd8156fe7d73c0887a9bf01a919610738 Mon Sep 17 00:00:00 2001 From: Simon Gellis Date: Tue, 28 Oct 2025 11:41:11 -0400 Subject: [PATCH] chore: enable clippy on drep_state --- .../workflows/run-tests-on-push-to-main.yml | 1 + modules/drep_state/src/drep_state.rs | 65 ++++++++++--------- modules/drep_state/src/state.rs | 8 +-- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/.github/workflows/run-tests-on-push-to-main.yml b/.github/workflows/run-tests-on-push-to-main.yml index 89066338..4e2ec85b 100644 --- a/.github/workflows/run-tests-on-push-to-main.yml +++ b/.github/workflows/run-tests-on-push-to-main.yml @@ -34,6 +34,7 @@ jobs: --package acropolis_module_chain_store \ --package acropolis_module_consensus \ --package acropolis_module_drdd_state \ + --package acropolis_module_drep_state \ --package acropolis_module_epochs_state \ --package acropolis_module_genesis_bootstrapper \ --package acropolis_module_mithril_snapshot_fetcher \ diff --git a/modules/drep_state/src/drep_state.rs b/modules/drep_state/src/drep_state.rs index eaaaf208..c1b14cf1 100644 --- a/modules/drep_state/src/drep_state.rs +++ b/modules/drep_state/src/drep_state.rs @@ -105,7 +105,7 @@ impl DRepState { ref block_info, CardanoMessage::ProtocolParams(params), )) => { - Self::check_sync(¤t_block, &block_info, "params"); + Self::check_sync(¤t_block, block_info, "params"); if let Some(conway) = ¶ms.params.conway { state .update_drep_expirations( @@ -123,7 +123,7 @@ impl DRepState { // Publish DRep state at the end of the epoch if let Some(ref block) = current_block { let dreps = state.active_drep_list(); - drep_state_publisher.publish_drep_state(&block, dreps).await?; + drep_state_publisher.publish_drep_state(block, dreps).await?; } } @@ -135,7 +135,7 @@ impl DRepState { )) => { let span = info_span!("drep_state.handle_certs", block = block_info.number); async { - Self::check_sync(¤t_block, &block_info, "certs"); + Self::check_sync(¤t_block, block_info, "certs"); state .process_certificates( context.clone(), @@ -163,7 +163,7 @@ impl DRepState { )) => { let span = info_span!("drep_state.handle_votes", block = block_info.number); async { - Self::check_sync(¤t_block, &block_info, "gov"); + Self::check_sync(¤t_block, block_info, "gov"); state .process_votes(&gov_msg.voting_procedures) .inspect_err(|e| error!("Votes handling error: {e:#}")) @@ -283,31 +283,32 @@ impl DRepState { }, GovernanceStateQuery::GetDRepInfoWithDelegators { drep_credential } => { match locked.current() { - Some(state) => match state.get_drep_info(&drep_credential) { - Ok(Some(info)) => match state.get_drep_delegators(&drep_credential) - { - Ok(Some(delegators)) => { - let response = DRepInfoWithDelegators { - info: DRepInfo { - deposit: info.deposit, - retired: info.retired, - expired: info.expired, - active_epoch: info.active_epoch, - last_active_epoch: info.last_active_epoch, - }, - delegators: delegators.to_vec(), - }; - - GovernanceStateQueryResponse::DRepInfoWithDelegators( - response, - ) + Some(state) => match state.get_drep_info(drep_credential) { + Ok(Some(info)) => { + match state.get_drep_delegators(drep_credential) { + Ok(Some(delegators)) => { + let response = DRepInfoWithDelegators { + info: DRepInfo { + deposit: info.deposit, + retired: info.retired, + expired: info.expired, + active_epoch: info.active_epoch, + last_active_epoch: info.last_active_epoch, + }, + delegators: delegators.to_vec(), + }; + + GovernanceStateQueryResponse::DRepInfoWithDelegators( + response, + ) + } + + Ok(None) => GovernanceStateQueryResponse::NotFound, + Err(msg) => { + GovernanceStateQueryResponse::Error(msg.to_string()) + } } - - Ok(None) => GovernanceStateQueryResponse::NotFound, - Err(msg) => { - GovernanceStateQueryResponse::Error(msg.to_string()) - } - }, + } Ok(None) => GovernanceStateQueryResponse::NotFound, Err(msg) => GovernanceStateQueryResponse::Error(msg.to_string()), @@ -319,7 +320,7 @@ impl DRepState { } GovernanceStateQuery::GetDRepDelegators { drep_credential } => { match locked.current() { - Some(state) => match state.get_drep_delegators(&drep_credential) { + Some(state) => match state.get_drep_delegators(drep_credential) { Ok(Some(delegators)) => { GovernanceStateQueryResponse::DRepDelegators( DRepDelegatorAddresses { @@ -337,7 +338,7 @@ impl DRepState { } GovernanceStateQuery::GetDRepMetadata { drep_credential } => { match locked.current() { - Some(state) => match state.get_drep_anchor(&drep_credential) { + Some(state) => match state.get_drep_anchor(drep_credential) { Ok(Some(anchor)) => GovernanceStateQueryResponse::DRepMetadata( Some(Some(anchor.clone())), ), @@ -352,7 +353,7 @@ impl DRepState { GovernanceStateQuery::GetDRepUpdates { drep_credential } => { match locked.current() { - Some(state) => match state.get_drep_updates(&drep_credential) { + Some(state) => match state.get_drep_updates(drep_credential) { Ok(Some(updates)) => { GovernanceStateQueryResponse::DRepUpdates(DRepUpdates { updates: updates.to_vec(), @@ -368,7 +369,7 @@ impl DRepState { } GovernanceStateQuery::GetDRepVotes { drep_credential } => { match locked.current() { - Some(state) => match state.get_drep_votes(&drep_credential) { + Some(state) => match state.get_drep_votes(drep_credential) { Ok(Some(votes)) => { GovernanceStateQueryResponse::DRepVotes(DRepVotes { votes: votes.to_vec(), diff --git a/modules/drep_state/src/state.rs b/modules/drep_state/src/state.rs index 4d561e1a..7995880f 100644 --- a/modules/drep_state/src/state.rs +++ b/modules/drep_state/src/state.rs @@ -257,7 +257,7 @@ impl State { return Ok(()); }; - let cfg = self.config.clone(); + let cfg = self.config; for (tx_hash, voting_procedures) in voting_procedures { for (voter, single_votes) in &voting_procedures.votes { let drep_cred = match voter { @@ -272,9 +272,9 @@ impl State { let votes = entry.votes.as_mut().unwrap(); - for (_, vp) in &single_votes.voting_procedures { + for vp in single_votes.voting_procedures.values() { votes.push(VoteRecord { - tx_hash: tx_hash.clone(), + tx_hash: *tx_hash, vote_index: vp.vote_index, vote: vp.vote.clone(), }); @@ -455,7 +455,7 @@ impl State { }; if create_if_missing { - let cfg = self.config.clone(); + let cfg = self.config; let entry = hist .entry(credential.clone()) .or_insert_with(|| HistoricalDRepState::from_config(&cfg));