@@ -448,6 +448,7 @@ pub(crate) struct BankFieldsToDeserialize {
448448// This is separated from BankFieldsToDeserialize to avoid cloning by using refs.
449449// So, sync fields with BankFieldsToDeserialize!
450450// all members are made public to remain Bank private and to make versioned serializer workable on this
451+ #[ derive( Debug ) ]
451452pub ( crate ) struct BankFieldsToSerialize < ' a > {
452453 pub ( crate ) blockhash_queue : & ' a RwLock < BlockhashQueue > ,
453454 pub ( crate ) ancestors : & ' a Ancestors ,
@@ -482,6 +483,46 @@ pub(crate) struct BankFieldsToSerialize<'a> {
482483 pub ( crate ) is_delta : bool ,
483484}
484485
486+ // Can't derive PartialEq because RwLock doesn't implement PartialEq
487+ impl PartialEq for Bank {
488+ fn eq ( & self , other : & Self ) -> bool {
489+ if ptr:: eq ( self , other) {
490+ return true ;
491+ }
492+ * self . blockhash_queue . read ( ) . unwrap ( ) == * other. blockhash_queue . read ( ) . unwrap ( )
493+ && self . ancestors == other. ancestors
494+ && * self . hash . read ( ) . unwrap ( ) == * other. hash . read ( ) . unwrap ( )
495+ && self . parent_hash == other. parent_hash
496+ && self . parent_slot == other. parent_slot
497+ && * self . hard_forks . read ( ) . unwrap ( ) == * other. hard_forks . read ( ) . unwrap ( )
498+ && self . transaction_count . load ( Relaxed ) == other. transaction_count . load ( Relaxed )
499+ && self . tick_height . load ( Relaxed ) == other. tick_height . load ( Relaxed )
500+ && self . signature_count . load ( Relaxed ) == other. signature_count . load ( Relaxed )
501+ && self . capitalization . load ( Relaxed ) == other. capitalization . load ( Relaxed )
502+ && self . max_tick_height == other. max_tick_height
503+ && self . hashes_per_tick == other. hashes_per_tick
504+ && self . ticks_per_slot == other. ticks_per_slot
505+ && self . ns_per_slot == other. ns_per_slot
506+ && self . genesis_creation_time == other. genesis_creation_time
507+ && self . slots_per_year == other. slots_per_year
508+ && self . unused == other. unused
509+ && self . slot == other. slot
510+ && self . epoch == other. epoch
511+ && self . block_height == other. block_height
512+ && self . collector_id == other. collector_id
513+ && self . collector_fees . load ( Relaxed ) == other. collector_fees . load ( Relaxed )
514+ && self . fee_calculator == other. fee_calculator
515+ && self . fee_rate_governor == other. fee_rate_governor
516+ && self . collected_rent . load ( Relaxed ) == other. collected_rent . load ( Relaxed )
517+ && self . rent_collector == other. rent_collector
518+ && self . epoch_schedule == other. epoch_schedule
519+ && * self . inflation . read ( ) . unwrap ( ) == * other. inflation . read ( ) . unwrap ( )
520+ && * self . stakes . read ( ) . unwrap ( ) == * other. stakes . read ( ) . unwrap ( )
521+ && self . epoch_stakes == other. epoch_stakes
522+ && self . is_delta . load ( Relaxed ) == other. is_delta . load ( Relaxed )
523+ }
524+ }
525+
485526#[ derive( Debug , PartialEq , Serialize , Deserialize , AbiExample , Default , Clone , Copy ) ]
486527pub struct RewardInfo {
487528 pub lamports : i64 , // Reward amount
@@ -883,7 +924,11 @@ impl Bank {
883924 ) ;
884925 assert_eq ! ( bank. epoch_schedule, genesis_config. epoch_schedule) ;
885926 assert_eq ! ( bank. epoch, bank. epoch_schedule. get_epoch( bank. slot) ) ;
886-
927+ bank. fee_rate_governor . lamports_per_signature = bank. fee_calculator . lamports_per_signature ;
928+ assert_eq ! (
929+ bank. fee_rate_governor. create_fee_calculator( ) ,
930+ bank. fee_calculator
931+ ) ;
887932 bank
888933 }
889934
@@ -3652,51 +3697,6 @@ impl Bank {
36523697 }
36533698 }
36543699
3655- pub fn compare_bank ( & self , dbank : & Bank ) {
3656- if ptr:: eq ( self , dbank) {
3657- return ;
3658- }
3659- assert_eq ! ( self . slot, dbank. slot) ;
3660- assert_eq ! ( self . collector_id, dbank. collector_id) ;
3661- assert_eq ! ( self . epoch_schedule, dbank. epoch_schedule) ;
3662- assert_eq ! ( self . hashes_per_tick, dbank. hashes_per_tick) ;
3663- assert_eq ! ( self . ticks_per_slot, dbank. ticks_per_slot) ;
3664- assert_eq ! ( self . parent_hash, dbank. parent_hash) ;
3665- assert_eq ! (
3666- self . tick_height. load( Relaxed ) ,
3667- dbank. tick_height. load( Relaxed )
3668- ) ;
3669- assert_eq ! ( self . is_delta. load( Relaxed ) , dbank. is_delta. load( Relaxed ) ) ;
3670-
3671- {
3672- let bh = self . hash . read ( ) . unwrap ( ) ;
3673- let dbh = dbank. hash . read ( ) . unwrap ( ) ;
3674- assert_eq ! ( * bh, * dbh) ;
3675- }
3676-
3677- {
3678- let st = self . stakes . read ( ) . unwrap ( ) ;
3679- let dst = dbank. stakes . read ( ) . unwrap ( ) ;
3680- assert_eq ! ( * st, * dst) ;
3681- }
3682-
3683- {
3684- let bhq = self . blockhash_queue . read ( ) . unwrap ( ) ;
3685- let dbhq = dbank. blockhash_queue . read ( ) . unwrap ( ) ;
3686- assert_eq ! ( * bhq, * dbhq) ;
3687- }
3688-
3689- {
3690- let sc = self . src . status_cache . read ( ) . unwrap ( ) ;
3691- let dsc = dbank. src . status_cache . read ( ) . unwrap ( ) ;
3692- assert_eq ! ( * sc, * dsc) ;
3693- }
3694- assert_eq ! (
3695- self . rc. accounts. bank_hash_at( self . slot) ,
3696- dbank. rc. accounts. bank_hash_at( dbank. slot)
3697- ) ;
3698- }
3699-
37003700 pub fn clean_accounts ( & self , skip_last : bool ) {
37013701 let max_clean_slot = if skip_last {
37023702 // Don't clean the slot we're snapshotting because it may have zero-lamport
0 commit comments