diff --git a/src/peer_manager.rs b/src/peer_manager.rs index 617f1c4ed2..351b12c71f 100644 --- a/src/peer_manager.rs +++ b/src/peer_manager.rs @@ -360,6 +360,11 @@ impl PeerManager { ); } + /// Removes any existing candidate + pub fn clear_candidate(&mut self) { + self.candidate = Candidate::None; + } + /// Adds a potential candidate to the candidate list setting its state to `VotedFor`. If /// another ongoing (i.e. unapproved) candidate exists, or if the candidate is unsuitable for /// adding to our section, returns an error. diff --git a/src/states/node.rs b/src/states/node.rs index 36f7816e3d..e7e0aac416 100644 --- a/src/states/node.rs +++ b/src/states/node.rs @@ -991,6 +991,10 @@ impl Node { self.gen_pfx_info = Some(gen_pfx_info); let _ = self.init_parsec()?; // We don't reset the chain on prefix change. + // Clear any pending candidate + // TODO: maybe also disconnect if currently connected. + self.peer_mgr.clear_candidate(); + let neighbour_infos: Vec<_> = self.chain.neighbour_infos().cloned().collect(); for ni in neighbour_infos { if sibling_pfx != *ni.prefix() { @@ -1021,8 +1025,6 @@ impl Node { cached_events .iter() .filter(|event| match **event { - // FIXME: once has_unconsensused_observations only considers votes than Obs - // can enable this similar to Offline event NetworkEvent::Online(_pub_id, _) => false, NetworkEvent::Offline(pub_id) => { our_pfx.matches(pub_id.name()) && !completed_events.contains(event) diff --git a/tests/mock_crust/churn.rs b/tests/mock_crust/churn.rs index c6f0d607d4..6d7a72dbdc 100644 --- a/tests/mock_crust/churn.rs +++ b/tests/mock_crust/churn.rs @@ -155,7 +155,7 @@ fn random_churn( let len = nodes.len(); let section_count = count_sections(nodes); if section_count > 1 && !rng.gen_weighted_bool(section_count as u32) { - // Use min_sec_size than section size to prevent collapsing any groups. + // Use min_sec_size rather than section size to prevent collapsing any groups. let max_drop = (nodes[0].chain().min_sec_size() - 1) * (QUORUM_DENOMINATOR - QUORUM_NUMERATOR) / QUORUM_DENOMINATOR;