Skip to content

Commit 0d43013

Browse files
authored
Merge pull request #167 from input-output-hk/refactor/delegations
extend KeyContribution struct
2 parents e21949a + 502f129 commit 0d43013

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

snapshot-lib/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub use fraction::Fraction;
22
use jormungandr_lib::{crypto::account::Identifier, interfaces::Value};
3-
use proptest::prelude::Arbitrary;
3+
use registration::MainnetStakeAddress;
44
use registration::{Delegations, MainnetRewardAddress, VotingRegistration};
55
use serde::{Deserialize, Serialize};
66
use std::{borrow::Borrow, collections::BTreeMap, iter::Iterator, num::NonZeroU64};
@@ -36,6 +36,7 @@ pub enum Error {
3636
/// Contribution to a voting key for some registration
3737
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
3838
pub struct KeyContribution {
39+
pub stake_public_key: MainnetStakeAddress,
3940
pub reward_address: MainnetRewardAddress,
4041
pub value: u64,
4142
}
@@ -79,12 +80,14 @@ impl Snapshot {
7980
reward_address,
8081
delegations,
8182
voting_power,
83+
stake_public_key,
8284
..
8385
} = reg;
8486

8587
match delegations {
8688
Delegations::Legacy(vk) => {
8789
acc.entry(vk).or_default().push(KeyContribution {
90+
stake_public_key,
8891
reward_address,
8992
value: voting_power.into(),
9093
});
@@ -103,6 +106,7 @@ impl Snapshot {
103106
})
104107
.map(|(vk, value)| {
105108
acc.entry(vk).or_default().push(KeyContribution {
109+
stake_public_key: stake_public_key.clone(),
106110
reward_address: reward_address.clone(),
107111
value: value.get(),
108112
});
@@ -111,6 +115,7 @@ impl Snapshot {
111115
.sum::<u64>()
112116
});
113117
acc.entry(last.0).or_default().push(KeyContribution {
118+
stake_public_key,
114119
reward_address,
115120
value: voting_power - others_total_vp,
116121
});

0 commit comments

Comments
 (0)