Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

NeighbourInfo cleanup and send ParsecPoke to all members #1579

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions src/chain/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,23 +948,16 @@ impl Chain {
return Some(*pfx);
}

let is_newer =
|other: &NeighbourSigs| other.sec_info().version() > nsigs.sec_info().version();
// Remove older compatible neighbour prefixes.
let is_newer = |(other_pfx, other_sigs): (&Prefix<XorName>, &NeighbourSigs)| {
other_pfx.is_compatible(pfx)
&& other_sigs.sec_info().version() > nsigs.sec_info().version()
};

// Check if we have a newer version of parent pfx.
let ppfx = pfx.popped();
if self.neighbour_infos.get(&ppfx).map_or(false, &is_newer) {
if self.neighbour_infos.iter().any(is_newer) {
return Some(*pfx);
}

// Check if we have a newer version of either child pfx.
let pfx0 = pfx.pushed(false);
let pfx1 = pfx.pushed(true);
if self.neighbour_infos.get(&pfx0).map_or(false, &is_newer)
|| self.neighbour_infos.get(&pfx1).map_or(false, &is_newer)
{
return Some(*pfx);
}
None
})
.collect();
Expand Down
29 changes: 20 additions & 9 deletions src/states/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2763,11 +2763,21 @@ impl Node {
}
}

// Sends a `ParsecPoke` message to trigger a gossip request from current section members to us.
//
// TODO: Should restrict targets to few(counter churn-threshold)/single.
// Currently this can result in incoming spam of gossip history from everyone.
// Can also just be a single target once node-ageing makes Offline votes Opaque which should
// remove invalid test failures for unaccumulated parsec::Remove blocks.
fn send_parsec_poke(&mut self) {
let (version, recipient) = if let Some(gen_pfx_info) = self.gen_pfx_info.as_ref() {
let recipients = gen_pfx_info.latest_info.members().iter().collect_vec();
let index = utils::rand_index(recipients.len());
(*gen_pfx_info.our_info.version(), *recipients[index])
let (version, recipients) = if let Some(gen_pfx_info) = self.gen_pfx_info.as_ref() {
let recipients = gen_pfx_info
.latest_info
.members()
.iter()
.cloned()
.collect_vec();
(*gen_pfx_info.our_info.version(), recipients)
} else {
log_or_panic!(
LogLevel::Error,
Expand All @@ -2776,11 +2786,12 @@ impl Node {
);
return;
};

self.send_message(
&recipient,
Message::Direct(DirectMessage::ParsecPoke(version)),
)
for recipient in recipients {
self.send_message(
&recipient,
Message::Direct(DirectMessage::ParsecPoke(version)),
);
}
}

// Drop peers to which we think we have a connection, but where Crust reports
Expand Down