PR comments

This commit is contained in:
Carl
2019-03-18 20:23:34 -07:00
committed by Grimes
parent a2c1fa7cb4
commit 4df79b653b
3 changed files with 25 additions and 35 deletions

View File

@@ -895,7 +895,7 @@ impl Bank {
self.is_delta.load(Ordering::Relaxed) && self.tick_height() == max_tick_height
}
pub fn is_descendant_of(&self, parent: u64) -> bool {
pub fn is_in_subtree_of(&self, parent: u64) -> bool {
if self.slot() == parent {
return true;
}
@@ -1729,7 +1729,7 @@ mod tests {
}
#[test]
fn test_is_descendant_of() {
fn test_is_in_subtree_of() {
let (genesis_block, _) = GenesisBlock::new(1);
let parent = Arc::new(Bank::new(&genesis_block));
// Bank 1
@@ -1740,15 +1740,15 @@ mod tests {
let bank5 = Bank::new_from_parent(&bank, &Pubkey::default(), 5);
// Parents of bank 2: 0 -> 1 -> 2
assert!(bank2.is_descendant_of(0));
assert!(bank2.is_descendant_of(1));
assert!(bank2.is_descendant_of(2));
assert!(!bank2.is_descendant_of(3));
assert!(bank2.is_in_subtree_of(0));
assert!(bank2.is_in_subtree_of(1));
assert!(bank2.is_in_subtree_of(2));
assert!(!bank2.is_in_subtree_of(3));
// Parents of bank 3: 0 -> 1 -> 5
assert!(bank5.is_descendant_of(0));
assert!(bank5.is_descendant_of(1));
assert!(!bank5.is_descendant_of(2));
assert!(!bank5.is_descendant_of(4));
// Parents of bank 5: 0 -> 1 -> 5
assert!(bank5.is_in_subtree_of(0));
assert!(bank5.is_in_subtree_of(1));
assert!(!bank5.is_in_subtree_of(2));
assert!(!bank5.is_in_subtree_of(4));
}
}