@@ -12,6 +12,7 @@ use std::env;
1212use std:: time:: Instant ;
1313
1414// Simple counter callback that doesn't store data in memory
15+ #[ derive( Default ) ]
1516struct CountingCallbacks {
1617 metadata : Option < SnapshotMetadata > ,
1718 utxo_count : u64 ,
@@ -26,24 +27,6 @@ struct CountingCallbacks {
2627 sample_proposals : Vec < GovernanceProposal > ,
2728}
2829
29- impl Default for CountingCallbacks {
30- fn default ( ) -> Self {
31- Self {
32- metadata : None ,
33- utxo_count : 0 ,
34- pool_count : 0 ,
35- account_count : 0 ,
36- drep_count : 0 ,
37- proposal_count : 0 ,
38- sample_utxos : Vec :: new ( ) ,
39- sample_pools : Vec :: new ( ) ,
40- sample_accounts : Vec :: new ( ) ,
41- sample_dreps : Vec :: new ( ) ,
42- sample_proposals : Vec :: new ( ) ,
43- }
44- }
45- }
46-
4730impl UtxoCallback for CountingCallbacks {
4831 fn on_utxo ( & mut self , utxo : UtxoEntry ) -> Result < ( ) > {
4932 self . utxo_count += 1 ;
@@ -62,7 +45,7 @@ impl UtxoCallback for CountingCallbacks {
6245 self . sample_utxos . push ( utxo) ;
6346 }
6447 // Progress reporting every million UTXOs
65- if self . utxo_count > 0 && self . utxo_count % 1000000 == 0 {
48+ if self . utxo_count > 0 && self . utxo_count . is_multiple_of ( 1000000 ) {
6649 eprintln ! ( " Parsed {} UTXOs..." , self . utxo_count) ;
6750 }
6851 Ok ( ( ) )
@@ -95,7 +78,7 @@ impl PoolCallback for CountingCallbacks {
9578impl StakeCallback for CountingCallbacks {
9679 fn on_accounts ( & mut self , accounts : Vec < AccountState > ) -> Result < ( ) > {
9780 self . account_count = accounts. len ( ) ;
98- if accounts. len ( ) > 0 {
81+ if ! accounts. is_empty ( ) {
9982 eprintln ! ( "✓ Parsed {} stake accounts" , accounts. len( ) ) ;
10083
10184 // Show first 10 accounts
@@ -152,7 +135,7 @@ impl DRepCallback for CountingCallbacks {
152135impl ProposalCallback for CountingCallbacks {
153136 fn on_proposals ( & mut self , proposals : Vec < GovernanceProposal > ) -> Result < ( ) > {
154137 self . proposal_count = proposals. len ( ) ;
155- if proposals. len ( ) > 0 {
138+ if ! proposals. is_empty ( ) {
156139 eprintln ! ( "✓ Parsed {} governance proposals" , proposals. len( ) ) ;
157140
158141 // Show first 10 proposals
0 commit comments