1- use crate :: rewards:: voters:: { account_hex_to_address , VoteCount } ;
1+ use crate :: rewards:: voters:: VoteCount ;
22use crate :: stats:: distribution:: Stats ;
33use chain_addr:: { Discrimination , Kind } ;
44use chain_crypto:: Ed25519 ;
55use chain_impl_mockchain:: vote:: CommitteeId ;
66use jormungandr_automation:: testing:: block0:: get_block;
7- use jormungandr_lib:: interfaces :: Address ;
8- use jormungandr_lib :: interfaces :: Block0Configuration ;
9- use jormungandr_lib :: interfaces:: Initial ;
10- use jormungandr_lib :: interfaces :: InitialUTxO ;
7+ use jormungandr_lib:: {
8+ crypto :: account :: Identifier ,
9+ interfaces:: { Address , Block0Configuration , Initial , InitialUTxO } ,
10+ } ;
1111use std:: path:: Path ;
1212
1313fn blacklist_addresses ( genesis : & Block0Configuration ) -> Vec < Address > {
@@ -35,7 +35,7 @@ fn blacklist_addresses(genesis: &Block0Configuration) -> Vec<Address> {
3535 . collect ( )
3636}
3737
38- fn vote_counts_as_addresses (
38+ fn vote_counts_as_utxo (
3939 votes_count : VoteCount ,
4040 genesis : & Block0Configuration ,
4141) -> Vec < ( InitialUTxO , u32 ) > {
@@ -45,15 +45,8 @@ fn vote_counts_as_addresses(
4545 . filter_map ( |initials| {
4646 if let Initial :: Fund ( funds) = initials {
4747 for utxo in funds {
48- if let Some ( ( _, votes_count) ) = votes_count. iter ( ) . find ( |( address, _) | {
49- account_hex_to_address (
50- address. to_string ( ) ,
51- genesis. blockchain_configuration . discrimination ,
52- )
53- . unwrap ( )
54- == utxo. address
55- } ) {
56- return Some ( ( utxo. clone ( ) , * votes_count as u32 ) ) ;
48+ if let Some ( vote_count) = votes_count. get ( & addr_to_hex ( & utxo. address ) ) {
49+ return Some ( ( utxo. clone ( ) , * vote_count as u32 ) ) ;
5750 }
5851 }
5952 }
@@ -62,6 +55,16 @@ fn vote_counts_as_addresses(
6255 . collect ( )
6356}
6457
58+ pub fn addr_to_hex ( address : & Address ) -> String {
59+ match & address. 1 . 1 {
60+ Kind :: Account ( pk) => {
61+ let id: Identifier = pk. clone ( ) . into ( ) ;
62+ id. to_hex ( )
63+ }
64+ _ => unimplemented ! ( ) ,
65+ }
66+ }
67+
6568pub fn calculate_active_wallet_distribution < S : Into < String > , P : AsRef < Path > > (
6669 stats : Stats ,
6770 block0 : S ,
@@ -77,7 +80,7 @@ pub fn calculate_active_wallet_distribution<S: Into<String>, P: AsRef<Path>>(
7780 ) ?) ?;
7881
7982 let blacklist = blacklist_addresses ( & genesis) ;
80- let initials = vote_counts_as_addresses ( vote_count, & genesis) ;
83+ let initials = vote_counts_as_utxo ( vote_count, & genesis) ;
8184
8285 calculate_wallet_distribution_from_initials_utxo (
8386 stats,
0 commit comments