Skip to content

Commit

Permalink
Don't pass in extra ancestors param to Bank::get_fields_to_serialize() (
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored May 14, 2024
1 parent d1afd78 commit 4f10d58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
9 changes: 3 additions & 6 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ pub struct BankFieldsToDeserialize {
#[derive(Debug)]
pub(crate) struct BankFieldsToSerialize<'a> {
pub(crate) blockhash_queue: &'a RwLock<BlockhashQueue>,
pub(crate) ancestors: &'a AncestorsForSerialization,
pub(crate) ancestors: AncestorsForSerialization,
pub(crate) hash: Hash,
pub(crate) parent_hash: Hash,
pub(crate) parent_slot: Slot,
Expand Down Expand Up @@ -1716,13 +1716,10 @@ impl Bank {
}

/// Return subset of bank fields representing serializable state
pub(crate) fn get_fields_to_serialize<'a>(
&'a self,
ancestors: &'a HashMap<Slot, usize>,
) -> BankFieldsToSerialize<'a> {
pub(crate) fn get_fields_to_serialize(&self) -> BankFieldsToSerialize {
BankFieldsToSerialize {
blockhash_queue: &self.blockhash_queue,
ancestors,
ancestors: AncestorsForSerialization::from(&self.ancestors),
hash: *self.hash.read().unwrap(),
parent_hash: self.parent_hash,
parent_slot: self.parent_slot,
Expand Down
10 changes: 4 additions & 6 deletions runtime/src/serde_snapshot/newer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl From<DeserializableVersionedBank> for BankFieldsToDeserialize {
#[derive(Serialize)]
struct SerializableVersionedBank<'a> {
blockhash_queue: &'a RwLock<BlockhashQueue>,
ancestors: &'a AncestorsForSerialization,
ancestors: AncestorsForSerialization,
hash: Hash,
parent_hash: Hash,
parent_slot: Slot,
Expand Down Expand Up @@ -194,8 +194,7 @@ impl<'a> TypeContext<'a> for Context {
where
Self: std::marker::Sized,
{
let ancestors = HashMap::from(&serializable_bank.bank.ancestors);
let fields = serializable_bank.bank.get_fields_to_serialize(&ancestors);
let fields = serializable_bank.bank.get_fields_to_serialize();
let lamports_per_signature = fields.fee_rate_governor.lamports_per_signature;
let bank_fields_to_serialize = (
SerializableVersionedBank::from(fields),
Expand Down Expand Up @@ -226,8 +225,7 @@ impl<'a> TypeContext<'a> for Context {
where
Self: std::marker::Sized,
{
let ancestors = HashMap::from(&serializable_bank.bank.ancestors);
let fields = serializable_bank.bank.get_fields_to_serialize(&ancestors);
let fields = serializable_bank.bank.get_fields_to_serialize();
(
SerializableVersionedBank::from(fields),
SerializableAccountsDb::<'a, Self> {
Expand Down Expand Up @@ -370,7 +368,7 @@ impl<'a> TypeContext<'a> for Context {

let bank = SerializableVersionedBank {
blockhash_queue: &blockhash_queue,
ancestors: &rhs.ancestors,
ancestors: rhs.ancestors,
hash: rhs.hash,
parent_hash: rhs.parent_hash,
parent_slot: rhs.parent_slot,
Expand Down

0 comments on commit 4f10d58

Please sign in to comment.