33// ================================================================================================
44
55use anyhow:: { Context , Error , Result } ;
6- use log:: info;
6+ use log:: { error , info} ;
77
88use minicbor:: Decoder ;
99use serde:: Serialize ;
@@ -14,6 +14,7 @@ pub use crate::hash::Hash;
1414use crate :: snapshot:: pool_params:: PoolParams ;
1515use crate :: snapshot:: streaming_snapshot;
1616pub use crate :: stake_addresses:: { AccountState , StakeAddressState } ;
17+ use crate :: PoolId ;
1718pub use crate :: StakeCredential ;
1819use crate :: { address:: StakeAddress , types, NetworkId , PoolRegistration } ;
1920
@@ -83,9 +84,9 @@ pub struct Snapshot {
8384 /// snapshot_stake: stake distribution map (credential -> lovelace amount)
8485 pub snapshot_stake : VMap < StakeCredential , i64 > ,
8586 // snapshot_delegations: vmap<credential, key_hash<stake_pool>>,)
86- pub snapshot_delegations : VMap < StakeCredential , Hash < 28 > > ,
87+ pub snapshot_delegations : VMap < StakeCredential , PoolId > ,
8788 // snapshot_pool_params: vmap<key_hash<stake_pool>, pool_params>,
88- pub snapshot_pool_params : VMap < Hash < 28 > , PoolRegistration > ,
89+ pub snapshot_pool_params : VMap < PoolId , PoolRegistration > ,
8990}
9091
9192impl Snapshot {
@@ -112,14 +113,14 @@ impl Snapshot {
112113 // Skip delegations (second element)
113114 info ! ( " {snapshot_name} snapshot - parsing snapshot_delegations..." ) ;
114115
115- let delegations: VMap < StakeCredential , Hash < 28 > > =
116+ let delegations: VMap < StakeCredential , PoolId > =
116117 decoder. decode ( ) . context ( "Failed to parse snapshot_delegations" ) ?;
117118
118119 info ! (
119120 " {snapshot_name} snapshot - parsing snapshot_pool_registration..."
120121 ) ;
121122 // pool_registration (third element)
122- let pools: VMap < Hash < 28 > , PoolParams > = decoder
123+ let pools: VMap < PoolId , PoolParams > = decoder
123124 . decode ( )
124125 . context ( "Failed to parse snapshot_pool_registration" ) ?;
125126 let registration = VMap (
@@ -130,7 +131,12 @@ impl Snapshot {
130131 // Convert RewardAccount (Vec<u8>) to StakeAddress
131132 let reward_account =
132133 StakeAddress :: from_binary ( & params. reward_account . 0 )
133- . unwrap_or_else ( |_| StakeAddress :: default ( ) ) ;
134+ . unwrap_or_else ( |_|
135+ {
136+ error ! ( "Failed to parse reward account for pool {pool_id}, using default" ) ;
137+ StakeAddress :: default ( )
138+ }
139+ ) ;
134140
135141 // Convert Set<AddrKeyhash> to Vec<StakeAddress>
136142 let pool_owners: Vec < StakeAddress > = params
@@ -140,7 +146,7 @@ impl Snapshot {
140146 . map ( |keyhash| {
141147 StakeAddress :: new (
142148 StakeCredential :: AddrKeyHash ( keyhash) ,
143- NetworkId :: Mainnet ,
149+ NetworkId :: Mainnet , // TODO: Make network configurable or get it from parameters
144150 )
145151 } )
146152 . collect ( ) ;
0 commit comments