Skip to content

Commit 981ff15

Browse files
committed
Replace KeyHash with StakeAddress in get_drep_delegators
1 parent 61a6d48 commit 981ff15

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

common/src/queries/accounts.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use std::collections::HashMap;
22

3-
use crate::{
4-
DRepChoice, KeyHash, PoolId, PoolLiveStakeInfo, RewardType, StakeAddress, TxIdentifier,
5-
};
3+
use crate::{DRepChoice, PoolId, PoolLiveStakeInfo, RewardType, StakeAddress, TxIdentifier};
64

75
pub const DEFAULT_ACCOUNTS_QUERY_TOPIC: (&str, &str) =
86
("accounts-state-query-topic", "cardano.query.accounts");
@@ -191,5 +189,5 @@ pub struct PoolDelegators {
191189

192190
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
193191
pub struct DrepDelegators {
194-
pub delegators: Vec<(KeyHash, u64)>,
192+
pub delegators: Vec<(StakeAddress, u64)>,
195193
}

common/src/stake_addresses.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
math::update_value_with_delta, messages::DRepDelegationDistribution, DRepChoice,
3-
DRepCredential, DelegatedStake, KeyHash, Lovelace, PoolId, PoolLiveStakeInfo, StakeAddress,
3+
DRepCredential, DelegatedStake, Lovelace, PoolId, PoolLiveStakeInfo, StakeAddress,
44
StakeAddressDelta, Withdrawal,
55
};
66
use anyhow::Result;
@@ -184,15 +184,15 @@ impl StakeAddressMap {
184184
}
185185

186186
/// Get DRep Delegators with live_stakes
187-
pub fn get_drep_delegators(&self, drep: &DRepChoice) -> Vec<(KeyHash, u64)> {
187+
pub fn get_drep_delegators(&self, drep: &DRepChoice) -> Vec<(StakeAddress, u64)> {
188188
// Find stake addresses delegated to drep
189-
let delegators: Vec<(KeyHash, u64)> = self
189+
let delegators: Vec<(StakeAddress, u64)> = self
190190
.inner
191191
.iter()
192192
.filter_map(|(stake_address, sas)| match sas.delegated_drep.as_ref() {
193193
Some(delegated_drep) => {
194194
if delegated_drep.eq(drep) {
195-
Some((*stake_address.get_hash(), sas.utxo_value))
195+
Some((stake_address.clone(), sas.utxo_value))
196196
} else {
197197
None
198198
}
@@ -549,7 +549,7 @@ impl StakeAddressMap {
549549
mod tests {
550550
use super::*;
551551
use crate::hash::Hash;
552-
use crate::{NetworkId, StakeAddress, StakeCredential};
552+
use crate::{KeyHash, NetworkId, StakeAddress, StakeCredential};
553553

554554
const STAKE_KEY_HASH: KeyHash = KeyHash::new([0x99; 28]);
555555
const STAKE_KEY_HASH_2: KeyHash = KeyHash::new([0xaa; 28]);

modules/accounts_state/src/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl State {
175175
}
176176

177177
/// Get Drep Delegators with live_stakes
178-
pub fn get_drep_delegators(&self, drep: &DRepChoice) -> Vec<(KeyHash, u64)> {
178+
pub fn get_drep_delegators(&self, drep: &DRepChoice) -> Vec<(StakeAddress, u64)> {
179179
self.stake_addresses.lock().unwrap().get_drep_delegators(drep)
180180
}
181181

0 commit comments

Comments
 (0)