Skip to content

Commit

Permalink
Change new_store method to use self (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris authored Jan 5, 2024
1 parent 7286cb1 commit 5c9ced2
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions firewood/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,10 +665,9 @@ impl Db {

/// Create a new mutable store and an alterable revision of the DB on top.
fn new_store(
&self,
cached_space: &Universe<Arc<CachedSpace>>,
reset_store_headers: bool,
payload_regn_nbit: u64,
cfg: &DbConfig,
) -> Result<(Universe<StoreRevMut>, DbRev<MutStore>), DbError> {
let mut offset = Db::PARAM_SIZE as usize;
let db_header: DiskAddress = DiskAddress::from(offset);
Expand Down Expand Up @@ -713,9 +712,9 @@ impl Db {
let mut rev: DbRev<CompactSpace<Node, StoreRevMut>> = Db::new_revision(
header_refs,
(store.merkle.meta.clone(), store.merkle.payload.clone()),
payload_regn_nbit,
cfg.payload_max_walk,
&cfg.rev,
self.payload_regn_nbit,
self.cfg.payload_max_walk,
&self.cfg.rev,
)?;
#[allow(clippy::unwrap_used)]
rev.flush_dirty().unwrap();
Expand Down Expand Up @@ -800,12 +799,7 @@ impl Db {
) -> Result<proposal::Proposal, DbError> {
let mut inner = self.inner.write();
let reset_store_headers = inner.reset_store_headers;
let (store, mut rev) = Db::new_store(
&inner.cached_space,
reset_store_headers,
self.payload_regn_nbit,
&self.cfg,
)?;
let (store, mut rev) = self.new_store(&inner.cached_space, reset_store_headers)?;

// Flip the reset flag after resetting the store headers.
if reset_store_headers {
Expand Down

0 comments on commit 5c9ced2

Please sign in to comment.