Correctly describe repair and retransmit peers (#2110)

This commit is contained in:
Sagar Dhawan 2018-12-11 15:51:47 -08:00 committed by GitHub
parent 9243bc58db
commit 4788a4f775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

View File

@ -263,6 +263,20 @@ impl ClusterInfo {
/// compute broadcast table
pub fn tvu_peers(&self) -> Vec<NodeInfo> {
let me = self.my_data().id;
self.gossip
.crds
.table
.values()
.filter_map(|x| x.value.contact_info())
.filter(|x| x.id != me)
.filter(|x| ContactInfo::is_valid_address(&x.tvu))
.cloned()
.collect()
}
/// all peers that have a valid tvu except the leader
pub fn retransmit_peers(&self) -> Vec<NodeInfo> {
let me = self.my_data().id;
self.gossip
.crds
@ -275,6 +289,14 @@ impl ClusterInfo {
.collect()
}
/// all tvu peers with valid gossip addrs
pub fn repair_peers(&self) -> Vec<NodeInfo> {
ClusterInfo::tvu_peers(self)
.into_iter()
.filter(|x| ContactInfo::is_valid_address(&x.gossip))
.collect()
}
/// compute broadcast table
pub fn tpu_peers(&self) -> Vec<NodeInfo> {
let me = self.my_data().id;
@ -354,7 +376,7 @@ impl ClusterInfo {
let (me, orders): (NodeInfo, Vec<NodeInfo>) = {
// copy to avoid locking during IO
let s = obj.read().expect("'obj' read lock in pub fn retransmit");
(s.my_data().clone(), s.tvu_peers())
(s.my_data().clone(), s.retransmit_peers())
};
blob.write()
.unwrap()
@ -513,7 +535,7 @@ impl ClusterInfo {
pub fn window_index_request(&self, ix: u64) -> Result<(SocketAddr, Vec<u8>)> {
// find a peer that appears to be accepting replication, as indicated
// by a valid tvu port location
let valid: Vec<_> = self.gossip_peers();
let valid: Vec<_> = self.repair_peers();
if valid.is_empty() {
Err(ClusterInfoError::NoPeers)?;
}

View File

@ -74,7 +74,7 @@ pub fn repair(
}
}
let num_peers = rcluster_info.tvu_peers().len() as u64;
let num_peers = rcluster_info.repair_peers().len() as u64;
// Check if there's a max_entry_height limitation
let max_repair_entry_height = if max_entry_height == 0 {

View File

@ -176,7 +176,7 @@ impl WindowUtil for Window {
}
}
let num_peers = rcluster_info.tvu_peers().len() as u64;
let num_peers = rcluster_info.repair_peers().len() as u64;
let max_repair = if max_entry_height == 0 {
calculate_max_repair(
num_peers,