Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 7cca905

Browse files
committed
marginally improve Node::sanity_check
1 parent af8411f commit 7cca905

File tree

1 file changed

+6
-3
lines changed
  • frame/bags-list/src/list

1 file changed

+6
-3
lines changed

frame/bags-list/src/list/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,10 +773,13 @@ impl<T: Config> Node<T> {
773773
"node does not exist in the expected bag"
774774
);
775775

776+
let non_terminal_check = !self.is_terminal() &&
777+
expected_bag.head.as_ref() != Some(id) &&
778+
expected_bag.tail.as_ref() != Some(id);
779+
let terminal_check =
780+
expected_bag.head.as_ref() == Some(id) || expected_bag.tail.as_ref() == Some(id);
776781
frame_support::ensure!(
777-
!self.is_terminal() ||
778-
expected_bag.head.as_ref() == Some(id) ||
779-
expected_bag.tail.as_ref() == Some(id),
782+
non_terminal_check || terminal_check
780783
"a terminal node is neither its bag head or tail"
781784
);
782785

0 commit comments

Comments
 (0)