Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/run-tests-on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
65 changes: 33 additions & 32 deletions modules/drep_state/src/drep_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl DRepState {
ref block_info,
CardanoMessage::ProtocolParams(params),
)) => {
Self::check_sync(&current_block, &block_info, "params");
Self::check_sync(&current_block, block_info, "params");
if let Some(conway) = &params.params.conway {
state
.update_drep_expirations(
Expand All @@ -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?;
}
}

Expand All @@ -135,7 +135,7 @@ impl DRepState {
)) => {
let span = info_span!("drep_state.handle_certs", block = block_info.number);
async {
Self::check_sync(&current_block, &block_info, "certs");
Self::check_sync(&current_block, block_info, "certs");
state
.process_certificates(
context.clone(),
Expand Down Expand Up @@ -163,7 +163,7 @@ impl DRepState {
)) => {
let span = info_span!("drep_state.handle_votes", block = block_info.number);
async {
Self::check_sync(&current_block, &block_info, "gov");
Self::check_sync(&current_block, block_info, "gov");
state
.process_votes(&gov_msg.voting_procedures)
.inspect_err(|e| error!("Votes handling error: {e:#}"))
Expand Down Expand Up @@ -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()),
Expand All @@ -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 {
Expand All @@ -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())),
),
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions modules/drep_state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
});
Expand Down Expand Up @@ -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));
Expand Down