@@ -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 ,
@@ -505,6 +506,47 @@ impl fmt::Display for RewardType {
505506 }
506507}
507508
509+ #[ derive( Debug , PartialEq , Serialize , Deserialize , AbiExample , Clone , Copy ) ]
510+ // Can't derive PartialEq because RwLock doesn't implement PartialEq
511+ impl PartialEq for Bank {
512+ fn eq ( & self , other : & Self ) -> bool {
513+ if ptr:: eq ( self , other) {
514+ return true ;
515+ }
516+ * self . blockhash_queue . read ( ) . unwrap ( ) == * other. blockhash_queue . read ( ) . unwrap ( )
517+ && self . ancestors == other. ancestors
518+ && * self . hash . read ( ) . unwrap ( ) == * other. hash . read ( ) . unwrap ( )
519+ && self . parent_hash == other. parent_hash
520+ && self . parent_slot == other. parent_slot
521+ && * self . hard_forks . read ( ) . unwrap ( ) == * other. hard_forks . read ( ) . unwrap ( )
522+ && self . transaction_count . load ( Relaxed ) == other. transaction_count . load ( Relaxed )
523+ && self . tick_height . load ( Relaxed ) == other. tick_height . load ( Relaxed )
524+ && self . signature_count . load ( Relaxed ) == other. signature_count . load ( Relaxed )
525+ && self . capitalization . load ( Relaxed ) == other. capitalization . load ( Relaxed )
526+ && self . max_tick_height == other. max_tick_height
527+ && self . hashes_per_tick == other. hashes_per_tick
528+ && self . ticks_per_slot == other. ticks_per_slot
529+ && self . ns_per_slot == other. ns_per_slot
530+ && self . genesis_creation_time == other. genesis_creation_time
531+ && self . slots_per_year == other. slots_per_year
532+ && self . unused == other. unused
533+ && self . slot == other. slot
534+ && self . epoch == other. epoch
535+ && self . block_height == other. block_height
536+ && self . collector_id == other. collector_id
537+ && self . collector_fees . load ( Relaxed ) == other. collector_fees . load ( Relaxed )
538+ && self . fee_calculator == other. fee_calculator
539+ && self . fee_rate_governor == other. fee_rate_governor
540+ && self . collected_rent . load ( Relaxed ) == other. collected_rent . load ( Relaxed )
541+ && self . rent_collector == other. rent_collector
542+ && self . epoch_schedule == other. epoch_schedule
543+ && * self . inflation . read ( ) . unwrap ( ) == * other. inflation . read ( ) . unwrap ( )
544+ && * self . stakes . read ( ) . unwrap ( ) == * other. stakes . read ( ) . unwrap ( )
545+ && self . epoch_stakes == other. epoch_stakes
546+ && self . is_delta . load ( Relaxed ) == other. is_delta . load ( Relaxed )
547+ }
548+ }
549+
508550#[ derive( Debug , PartialEq , Serialize , Deserialize , AbiExample , Clone , Copy ) ]
509551pub struct RewardInfo {
510552 pub reward_type : RewardType ,
@@ -907,7 +949,11 @@ impl Bank {
907949 ) ;
908950 assert_eq ! ( bank. epoch_schedule, genesis_config. epoch_schedule) ;
909951 assert_eq ! ( bank. epoch, bank. epoch_schedule. get_epoch( bank. slot) ) ;
910-
952+ bank. fee_rate_governor . lamports_per_signature = bank. fee_calculator . lamports_per_signature ;
953+ assert_eq ! (
954+ bank. fee_rate_governor. create_fee_calculator( ) ,
955+ bank. fee_calculator
956+ ) ;
911957 bank
912958 }
913959
@@ -3699,51 +3745,6 @@ impl Bank {
36993745 }
37003746 }
37013747
3702- pub fn compare_bank ( & self , dbank : & Bank ) {
3703- if ptr:: eq ( self , dbank) {
3704- return ;
3705- }
3706- assert_eq ! ( self . slot, dbank. slot) ;
3707- assert_eq ! ( self . collector_id, dbank. collector_id) ;
3708- assert_eq ! ( self . epoch_schedule, dbank. epoch_schedule) ;
3709- assert_eq ! ( self . hashes_per_tick, dbank. hashes_per_tick) ;
3710- assert_eq ! ( self . ticks_per_slot, dbank. ticks_per_slot) ;
3711- assert_eq ! ( self . parent_hash, dbank. parent_hash) ;
3712- assert_eq ! (
3713- self . tick_height. load( Relaxed ) ,
3714- dbank. tick_height. load( Relaxed )
3715- ) ;
3716- assert_eq ! ( self . is_delta. load( Relaxed ) , dbank. is_delta. load( Relaxed ) ) ;
3717-
3718- {
3719- let bh = self . hash . read ( ) . unwrap ( ) ;
3720- let dbh = dbank. hash . read ( ) . unwrap ( ) ;
3721- assert_eq ! ( * bh, * dbh) ;
3722- }
3723-
3724- {
3725- let st = self . stakes . read ( ) . unwrap ( ) ;
3726- let dst = dbank. stakes . read ( ) . unwrap ( ) ;
3727- assert_eq ! ( * st, * dst) ;
3728- }
3729-
3730- {
3731- let bhq = self . blockhash_queue . read ( ) . unwrap ( ) ;
3732- let dbhq = dbank. blockhash_queue . read ( ) . unwrap ( ) ;
3733- assert_eq ! ( * bhq, * dbhq) ;
3734- }
3735-
3736- {
3737- let sc = self . src . status_cache . read ( ) . unwrap ( ) ;
3738- let dsc = dbank. src . status_cache . read ( ) . unwrap ( ) ;
3739- assert_eq ! ( * sc, * dsc) ;
3740- }
3741- assert_eq ! (
3742- self . rc. accounts. bank_hash_at( self . slot) ,
3743- dbank. rc. accounts. bank_hash_at( dbank. slot)
3744- ) ;
3745- }
3746-
37473748 pub fn clean_accounts ( & self ) {
37483749 self . rc . accounts . accounts_db . clean_accounts ( ) ;
37493750 }
0 commit comments