pub(super) fn process_pruned_blocks(
        &mut self,
        root_id: HashValue,
        mut newly_pruned_blocks: VecDeque<HashValue>,
    ) {
        // Update the next root
        self.root = self
            .id_to_block
            .get(&root_id)
            .expect("next_root_id must exist")
            .clone();

        counters::NUM_BLOCKS_IN_TREE.sub(newly_pruned_blocks.len() as i64);
        // The newly pruned blocks are pushed back to the deque pruned_block_ids.
        // In case the overall number of the elements is greater than the predefined threshold,
        // the oldest elements (in the front of the deque) are removed from the tree.
        self.pruned_block_ids.append(&mut newly_pruned_blocks);
        if self.pruned_block_ids.len() > self.max_pruned_blocks_in_mem {
            let num_blocks_to_remove = self.pruned_block_ids.len() - self.max_pruned_blocks_in_mem;
            for _ in 0..num_blocks_to_remove {
                if let Some(id) = self.pruned_block_ids.pop_front() {
                    self.remove_block(id);
                }
            }
        }
    }
/// Process the data returned by the prune_tree, they're separated because caller might
/// be interested in doing extra work e.g. delete from persistent storage.
/// Note that we do not necessarily remove the pruned blocks: they're kept in a separate buffer
/// for some time in order to enable other peers to retrieve the blocks even after they've
/// been committed.
Process the data returned by the prune_tree, they're separated because caller might
be interested in doing extra work e.g. delete from persistent storage.
Note that we do not necessarily remove the pruned blocks: they're kept in a separate buffer
for some time in order to enable other peers to retrieve the blocks even after they've
been committed.
Process the data returned by the prune_tree they ' re separated because caller might be interested in doing extra work e . g . delete from persistent storage . Note that we do not necessarily remove the pruned blocks : they ' re kept in a separate buffer for some time in order to enable other peers to retrieve the blocks even after they ' ve been committed .
pub(super) fn process_pruned_blocks(
        &mut self,
        root_id: HashValue,
        mut newly_pruned_blocks: VecDeque<HashValue>,
    ) {
        // Update the next root
        self.root = self
            .id_to_block
            .get(&root_id)
            .expect("next_root_id must exist")
            .clone();
        counters::NUM_BLOCKS_IN_TREE.sub(newly_pruned_blocks.len() as i64);
        // The newly pruned blocks are pushed back to the deque pruned_block_ids.
        // In case the overall number of the elements is greater than the predefined threshold,
        // the oldest elements (in the front of the deque) are removed from the tree.
        self.pruned_block_ids.append(&mut newly_pruned_blocks);
        if self.pruned_block_ids.len() > self.max_pruned_blocks_in_mem {
            let num_blocks_to_remove = self.pruned_block_ids.len() - self.max_pruned_blocks_in_mem;
            for _ in 0..num_blocks_to_remove {
                if let Some(id) = self.pruned_block_ids.pop_front() {
                    self.remove_block(id);
                }
            }
        }
    }
pub ( super ) fn process_pruned_blocks ( & mut self , root_id : HashValue , mut newly_pruned_blocks : VecDeque < HashValue > , ) { // Update the next root self . root = self . id_to_block . get ( & root_id ) . expect ( " " ) . clone ( ) ; counters :: NUM_BLOCKS_IN_TREE . sub ( newly_pruned_blocks . len ( ) as i64 ) ; // The newly pruned blocks are pushed back to the deque pruned_block_ids. // In case the overall number of the elements is greater than the predefined threshold, // the oldest elements (in the front of the deque) are removed from the tree. self . pruned_block_ids . append ( & mut newly_pruned_blocks ) ; if self . pruned_block_ids . len ( ) > self . max_pruned_blocks_in_mem { let num_blocks_to_remove = self . pruned_block_ids . len ( ) - self . max_pruned_blocks_in_mem ; for _ in 0 .. num_blocks_to_remove { if let Some ( id ) = self . pruned_block_ids . pop_front ( ) { self . remove_block ( id ) ; } } } }
Process the data returned by the prune_tree, they're separated because caller might
be interested in doing extra work e.g.
Process the data returned by the prune_tree they ' re separated because caller might be interested in doing extra work e . g .
&mut self
root_id
HashValue
newly_pruned_blocks
VecDeque<HashValue>
&mut self
root_id
HashValue
newly_pruned_blocks
VecDeque<HashValue>