Skip to content

Commit

Permalink
piecrust: clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed Nov 22, 2024
1 parent 378d674 commit 284dd47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
10 changes: 1 addition & 9 deletions piecrust/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl ContractStore {

fn session_with_base(&self, base: Option<Hash>) -> ContractSession {
let base_commit = base.and_then(|hash| {
self.commit_store.lock().unwrap().get_commit(&hash).cloned() //todo: clone
self.commit_store.lock().unwrap().get_commit(&hash).cloned()
});
ContractSession::new(
&self.root_dir,
Expand Down Expand Up @@ -569,12 +569,6 @@ fn index_merkle_from_path(
}
}

println!(
"COMMIT_FROM_DIR: merkle size={}, tree pos size={}",
merkle.len(),
merkle.tree_pos().len(),
);

Ok((index, merkle))
}

Expand Down Expand Up @@ -1084,8 +1078,6 @@ fn write_commit_inner<P: AsRef<Path>, S: AsRef<str>>(
tracing::trace!("persisting index started");
for (contract_id, element) in commit.index.iter() {
if commit_contracts.contains_key(contract_id) {
// todo: write element to disk at
// main/leaf/{contract_id}/{commit_id}
let element_dir_path = directories
.leaf_main_dir
.join(hex::encode(contract_id.as_bytes()))
Expand Down
6 changes: 3 additions & 3 deletions piecrust/src/store/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl ContractSession {
.base
.as_ref()
.map(|c| c.fast_clone(&mut self.contracts.keys()))
.unwrap_or(Commit::new(&self.commit_store, None)); // todo: what about None here
.unwrap_or(Commit::new(&self.commit_store, None));
for (contract, entry) in &self.contracts {
commit.insert(*contract, &entry.memory);
}
Expand All @@ -116,7 +116,7 @@ impl ContractSession {
let mut commit = self
.base
.clone()
.unwrap_or(Commit::new(&self.commit_store, None)); // todo: what about None here
.unwrap_or(Commit::new(&self.commit_store, None));
for (contract, entry) in &self.contracts {
commit.insert(*contract, &entry.memory);
}
Expand Down Expand Up @@ -152,7 +152,7 @@ impl ContractSession {
let (replier, receiver) = mpsc::sync_channel(1);

let mut contracts = BTreeMap::new();
let base = self.base.clone(); // todo: clone
let base = self.base.clone();

mem::swap(&mut self.contracts, &mut contracts);

Expand Down

0 comments on commit 284dd47

Please sign in to comment.