feat/view: assure heads in a view are sorted (#2493)

* feat/view: assure heads in a view are sorted

Allows O(n) comparisons, adds an alternate equiv relation
which takes O(n^2) for integrity verification.

Ref #2133

* revert: remove custom PartialEq impl, there are no duplicates

* fix: do not sort the live_heads, that alters the local view

* refactor/view: heads should not be public

* chore/spellcheck: add unfinalized

* fix/view: add missing len() and is_empty() fns

* quirk

* vec is not view

* Update node/network/approval-distribution/src/tests.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

* Update node/network/bridge/src/lib.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

* Update node/network/protocol/src/lib.rs

Co-authored-by: Andronik Ordian <write@reusable.software>

* fixup comment

* fix botched test

Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
Bernhard SchusterandAndronik Ordian authored and GitHub committed 2021-02-23 15:39:57 +00:00
1 parent 571651e326
commit e3f776abed
11 files changed
+85 -38

No files matched your search

@@ -684,7 +684,7 @@ async fn handle_network_update(
peer_state.awaited.retain(|relay_parent, _| view.contains(&relay_parent));
// introduce things from the new view.
for relay_parent in view.heads.iter() {
for relay_parent in view.iter() {
if let Entry::Vacant(entry) = peer_state.awaited.entry(*relay_parent) {
entry.insert(HashSet::new());