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

Commit

Permalink
Add blockstore generation from trees
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin committed Jun 23, 2020
1 parent 441ebad commit 09555ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ledger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ solana-stake-program = { path = "../programs/stake", version = "1.3.0" }
solana-vote-program = { path = "../programs/vote", version = "1.3.0" }
tempfile = "3.1.0"
thiserror = "1.0"
trees = "0.2.1"

[dependencies.rocksdb]
# Avoid the vendored bzip2 within rocksdb-sys that can cause linker conflicts
Expand Down
18 changes: 18 additions & 0 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use std::{
},
time::Duration,
};
use trees::{Tree, TreeWalk};

pub mod blockstore_purge;

Expand Down Expand Up @@ -303,6 +304,23 @@ impl Blockstore {
Ok((blockstore, signal_receiver, completed_slots_receiver))
}

pub fn add_tree(&self, forks: Tree<Slot>, is_orphan: bool) {
let mut walk = TreeWalk::from(forks);
while let Some(visit) = walk.get() {
let slot = visit.node().data;
if self.meta(slot).unwrap().is_some() {
walk.forward();
continue;
}
let parent = walk.get_parent().map(|n| n.data);
if parent.is_some() || !is_orphan {
let (shreds, _) = make_slot_entries(slot, parent.unwrap_or(slot), 1);
self.insert_shreds(shreds, None, false).unwrap();
}
walk.forward();
}
}

pub fn set_no_compaction(&mut self, no_compaction: bool) {
self.no_compaction = no_compaction;
}
Expand Down

0 comments on commit 09555ac

Please sign in to comment.