Skip to content

Commit

Permalink
Add comments for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofstuff committed Nov 6, 2024
1 parent 5249c75 commit 489e724
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions consensus/src/processes/pruning_proof/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl PruningProofManager {
let mut up_heap = BinaryHeap::with_capacity(capacity_estimate);
for header in proof.iter().flatten().cloned() {
if let Vacant(e) = dag.entry(header.hash) {
// TODO: Check if pow passes
let block_level = calc_block_level(&header, self.max_block_level);
self.headers_store.insert(header.hash, header.clone(), block_level).unwrap();

Expand Down
2 changes: 2 additions & 0 deletions consensus/src/processes/pruning_proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ impl PruningProofManager {
drop(pruning_point_write);
}

// Used in apply and validate
fn estimate_proof_unique_size(&self, proof: &PruningPointProof) -> usize {
let approx_history_size = proof[0][0].daa_score;
let approx_unique_full_levels = f64::log2(approx_history_size as f64 / self.pruning_proof_m as f64).max(0f64) as usize;
proof.iter().map(|l| l.len()).sum::<usize>().min((approx_unique_full_levels + 1) * self.pruning_proof_m as usize)
}

// Used in build and validate
fn block_at_depth(
&self,
ghostdag_store: &impl GhostdagStoreReader,
Expand Down

0 comments on commit 489e724

Please sign in to comment.