Fix the output from Gossip Discovery (#4067)

automerge
This commit is contained in:
Sagar Dhawan 2019-04-29 13:19:24 -07:00 committed by Grimes
parent c545e812d0
commit 4e41c81bc7
2 changed files with 10 additions and 7 deletions

View File

@ -249,7 +249,7 @@ impl ClusterInfo {
let nodes: Vec<_> = self
.all_peers()
.into_iter()
.map(|node| {
.map(|(node, last_updated)| {
if !ContactInfo::is_valid_address(&node.gossip) {
spy_nodes += 1;
}
@ -266,7 +266,7 @@ impl ClusterInfo {
tpu: {:20} | |\n \
rpc: {:20} | |\n",
addr_to_string(&node.gossip),
now.saturating_sub(node.wallclock),
now.saturating_sub(last_updated),
node.id,
if node.id == my_id { "(me)" } else { "" }.to_string(),
addr_to_string(&node.tpu),
@ -347,14 +347,17 @@ impl ClusterInfo {
.collect()
}
// All nodes in gossip, including spy nodes
pub(crate) fn all_peers(&self) -> Vec<ContactInfo> {
// All nodes in gossip (including spy nodes) and the last time we heard about them
pub(crate) fn all_peers(&self) -> Vec<(ContactInfo, u64)> {
self.gossip
.crds
.table
.values()
.filter_map(|x| x.value.contact_info())
.cloned()
.filter_map(|x| {
x.value
.contact_info()
.map(|ci| (ci.clone(), x.local_timestamp))
})
.collect()
}

View File

@ -294,7 +294,7 @@ impl RpcSol for RpcSolImpl {
Ok(cluster_info
.all_peers()
.iter()
.filter_map(|contact_info| {
.filter_map(|(contact_info, _)| {
if ContactInfo::is_valid_address(&contact_info.gossip) {
Some(RpcContactInfo {
id: contact_info.id.to_string(),