Ack on empty Gossip Pull Responses and keep Entrypoint around (#3881)

* Ack on empty Gossip Pull Responses and keep Entrypoint around

* Address comments and fix test

* Update core/src/cluster_info.rs

Co-Authored-By: sagar-solana <sagar@solana.com>

* Update core/src/cluster_info.rs

Co-Authored-By: sagar-solana <sagar@solana.com>
This commit is contained in:
Sagar Dhawan 2019-04-18 15:12:17 -07:00 committed by GitHub
parent aab410380e
commit 7e409a13cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 17 deletions

View File

@ -874,8 +874,6 @@ impl ClusterInfo {
.collect(); .collect();
if pr.is_empty() { if pr.is_empty() {
self.add_entrypoint(&mut pr); self.add_entrypoint(&mut pr);
} else {
self.entrypoint = None;
} }
pr.into_iter() pr.into_iter()
.map(|(peer, filter, gossip, self_info)| { .map(|(peer, filter, gossip, self_info)| {
@ -1092,13 +1090,9 @@ impl ClusterInfo {
.process_pull_request(caller, filter, now); .process_pull_request(caller, filter, now);
let len = data.len(); let len = data.len();
trace!("get updates since response {}", len); trace!("get updates since response {}", len);
if data.is_empty() {
trace!("no updates me {}", self_id);
vec![]
} else {
let rsp = Protocol::PullResponse(self_id, data); let rsp = Protocol::PullResponse(self_id, data);
// the remote side may not know his public IP:PORT, record what he looks like to us // The remote node may not know its public IP:PORT. Record what it looks like to us.
// this may or may not be correct for everybody but it's better than leaving him with // This may or may not be correct for everybody, but it's better than leaving the remote with
// an unspecified address in our table // an unspecified address in our table
if from.gossip.ip().is_unspecified() { if from.gossip.ip().is_unspecified() {
inc_new_counter_info!("cluster_info-window-request-updates-unspec-gossip", 1); inc_new_counter_info!("cluster_info-window-request-updates-unspec-gossip", 1);
@ -1107,7 +1101,6 @@ impl ClusterInfo {
inc_new_counter_info!("cluster_info-pull_request-rsp", len); inc_new_counter_info!("cluster_info-pull_request-rsp", len);
to_shared_blob(rsp, from.gossip).ok().into_iter().collect() to_shared_blob(rsp, from.gossip).ok().into_iter().collect()
} }
}
fn handle_pull_response(me: &Arc<RwLock<Self>>, from: &Pubkey, data: Vec<CrdsValue>) { fn handle_pull_response(me: &Arc<RwLock<Self>>, from: &Pubkey, data: Vec<CrdsValue>) {
let len = data.len(); let len = data.len();
let now = Instant::now(); let now = Instant::now();
@ -2221,5 +2214,5 @@ fn test_add_entrypoint() {
.unwrap() .unwrap()
.new_pull_requests(&HashMap::new()); .new_pull_requests(&HashMap::new());
assert_eq!(1, pulls.len()); assert_eq!(1, pulls.len());
assert_eq!(cluster_info.read().unwrap().entrypoint, None); assert_eq!(cluster_info.read().unwrap().entrypoint, Some(entrypoint));
} }