From bf61a6aeeeb3e988cc80b0d7e9ecb0c47be6a884 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 23 May 2023 15:53:29 +0200 Subject: [PATCH] refactor: rename take children function (#2795) --- crates/blockchain-tree/src/block_buffer.rs | 13 +++++++------ crates/blockchain-tree/src/blockchain_tree.rs | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/blockchain-tree/src/block_buffer.rs b/crates/blockchain-tree/src/block_buffer.rs index 976dd0930c..0524b7aeda 100644 --- a/crates/blockchain-tree/src/block_buffer.rs +++ b/crates/blockchain-tree/src/block_buffer.rs @@ -12,7 +12,7 @@ pub type BufferedBlocks = BTreeMap Vec { + pub fn remove_with_children(&mut self, parent: BlockNumHash) -> Vec { // remove parent block if present let mut taken = Vec::new(); if let Some(block) = self.remove_from_blocks(&parent) { @@ -212,7 +213,7 @@ mod tests { buffer.insert_block(block4); assert_eq!(buffer.len(), 4); - assert_eq!(buffer.take_all_children(main_parent), vec![block1, block2, block3]); + assert_eq!(buffer.remove_with_children(main_parent), vec![block1, block2, block3]); assert_eq!(buffer.len(), 1); } @@ -234,7 +235,7 @@ mod tests { assert_eq!(buffer.len(), 4); assert_eq!( buffer - .take_all_children(main_parent) + .remove_with_children(main_parent) .into_iter() .map(|b| (b.hash, b)) .collect::>(), @@ -266,7 +267,7 @@ mod tests { assert_eq!(buffer.len(), 4); assert_eq!( buffer - .take_all_children(block1.num_hash()) + .remove_with_children(block1.num_hash()) .into_iter() .map(|b| (b.hash, b)) .collect::>(), diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index 6fe0340370..abea78a7f7 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -744,7 +744,7 @@ impl BlockchainTree fn try_connect_buffered_blocks(&mut self, new_block: BlockNumHash) { trace!(target: "blockchain_tree", ?new_block, "try_connect_buffered_blocks"); - let include_blocks = self.buffered_blocks.take_all_children(new_block); + let include_blocks = self.buffered_blocks.remove_with_children(new_block); // insert block children for block in include_blocks.into_iter() { // dont fail on error, just ignore the block.