From e66464b14f9bafe78b659ce76bd5148324fe36db Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:52:09 -0400 Subject: [PATCH] chore: rename missing_parent to missing_ancestor (#3822) Co-authored-by: Matthias Seitz --- crates/blockchain-tree/src/blockchain_tree.rs | 10 +++++----- crates/consensus/beacon/src/engine/mod.rs | 4 +++- crates/interfaces/src/blockchain_tree/mod.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index 43fe1be6f..819d60d4c 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -201,7 +201,7 @@ impl BlockchainTree // check if block is disconnected if let Some(block) = self.buffered_blocks.block(block) { - return Ok(Some(BlockStatus::Disconnected { missing_parent: block.parent_num_hash() })) + return Ok(Some(BlockStatus::Disconnected { missing_ancestor: block.parent_num_hash() })) } Ok(None) @@ -360,7 +360,7 @@ impl BlockchainTree ) })?; - Ok(BlockStatus::Disconnected { missing_parent: lowest_ancestor.parent_num_hash() }) + Ok(BlockStatus::Disconnected { missing_ancestor: lowest_ancestor.parent_num_hash() }) } /// This tries to append the given block to the canonical chain. @@ -1274,7 +1274,7 @@ mod tests { assert_eq!( tree.insert_block(block2.clone()).unwrap(), InsertPayloadOk::Inserted(BlockStatus::Disconnected { - missing_parent: block2.parent_num_hash() + missing_ancestor: block2.parent_num_hash() }) ); @@ -1293,7 +1293,7 @@ mod tests { assert_eq!( tree.is_block_known(block2.num_hash()).unwrap(), - Some(BlockStatus::Disconnected { missing_parent: block2.parent_num_hash() }) + Some(BlockStatus::Disconnected { missing_ancestor: block2.parent_num_hash() }) ); // check if random block is known @@ -1575,7 +1575,7 @@ mod tests { assert_eq!( tree.insert_block(block2b.clone()).unwrap(), InsertPayloadOk::Inserted(BlockStatus::Disconnected { - missing_parent: block2b.parent_num_hash() + missing_ancestor: block2b.parent_num_hash() }) ); diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index f9fb030bf..e4f46ad9e 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -1262,7 +1262,9 @@ where // block is connected to the canonical chain, but not the current head self.try_make_sync_target_canonical(downloaded_num_hash); } - InsertPayloadOk::Inserted(BlockStatus::Disconnected { missing_parent }) => { + InsertPayloadOk::Inserted(BlockStatus::Disconnected { + missing_ancestor: missing_parent, + }) => { // block is not connected to the canonical head, we need to download its // missing branch first self.on_disconnected_block(downloaded_num_hash, missing_parent); diff --git a/crates/interfaces/src/blockchain_tree/mod.rs b/crates/interfaces/src/blockchain_tree/mod.rs index 8025c7901..d8334df7d 100644 --- a/crates/interfaces/src/blockchain_tree/mod.rs +++ b/crates/interfaces/src/blockchain_tree/mod.rs @@ -144,8 +144,8 @@ pub enum BlockStatus { Accepted, /// If blocks is not connected to canonical chain. Disconnected { - /// The lowest parent block that is not connected to the canonical chain. - missing_parent: BlockNumHash, + /// The lowest ancestor block that is not connected to the canonical chain. + missing_ancestor: BlockNumHash, }, }