Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
simplify the change
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 committed May 9, 2023
1 parent 6831285 commit 9a3b014
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
15 changes: 2 additions & 13 deletions program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ pub enum BlockRelation {
pub trait ForkGraph {
/// Returns the BlockRelation of A to B
fn relationship(&self, a: Slot, b: Slot) -> BlockRelation;

/// Returns the current root slot
fn root(&self) -> Slot;
}

/// Provides information about current working slot, and its ancestors
Expand Down Expand Up @@ -377,6 +374,7 @@ impl LoadedPrograms {

/// Before rerooting the blockstore this removes all programs of orphan forks
pub fn prune<F: ForkGraph>(&mut self, fork_graph: &F, new_root: Slot) {
let previous_root = self.latest_root;
self.entries.retain(|_key, second_level| {
let mut first_ancestor_found = false;
*second_level = second_level
Expand All @@ -388,7 +386,7 @@ impl LoadedPrograms {
matches!(relation, BlockRelation::Equal | BlockRelation::Descendant)
} else if !first_ancestor_found
&& (matches!(relation, BlockRelation::Ancestor)
|| fork_graph.root() > entry.deployment_slot)
|| previous_root > entry.deployment_slot)
{
first_ancestor_found = true;
first_ancestor_found
Expand Down Expand Up @@ -944,10 +942,6 @@ mod tests {
fn relationship(&self, _a: Slot, _b: Slot) -> BlockRelation {
self.relation
}

fn root(&self) -> Slot {
0
}
}

#[test]
Expand Down Expand Up @@ -997,7 +991,6 @@ mod tests {
#[derive(Default)]
struct TestForkGraphSpecific {
forks: Vec<Vec<Slot>>,
root: Slot,
}

impl TestForkGraphSpecific {
Expand Down Expand Up @@ -1034,10 +1027,6 @@ mod tests {
_ => BlockRelation::Unrelated,
}
}

fn root(&self) -> Slot {
self.root
}
}

struct TestWorkingSlot {
Expand Down
4 changes: 0 additions & 4 deletions runtime/src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,6 @@ impl ForkGraph for BankForks {
})
.unwrap_or(BlockRelation::Unknown)
}

fn root(&self) -> Slot {
self.root()
}
}

#[cfg(test)]
Expand Down

0 comments on commit 9a3b014

Please sign in to comment.