wasm fixes

This commit is contained in:
John Smith 2022-10-06 12:39:30 -04:00
parent e77577ba66
commit 1fdcd5ae45
3 changed files with 19 additions and 18 deletions

View File

@ -439,14 +439,17 @@ impl BucketEntryInner {
} }
} }
fn needs_constant_ping(&self, cur_ts: u64, interval: u64) -> bool { /// Return the last time we either saw a node, or asked it a question
// If we have not either seen the node, nor asked it a question in the last 'interval' fn latest_contact_time(&self) -> Option<u64> {
// then we should ping it self.peer_stats
let latest_contact_time = self
.peer_stats
.rpc_stats .rpc_stats
.last_seen_ts .last_seen_ts
.max(self.peer_stats.rpc_stats.last_question); .max(self.peer_stats.rpc_stats.last_question)
}
fn needs_constant_ping(&self, cur_ts: u64, interval: u64) -> bool {
// If we have not either seen the node in the last 'interval' then we should ping it
let latest_contact_time = self.latest_contact_time();
match latest_contact_time { match latest_contact_time {
None => true, None => true,
@ -468,14 +471,19 @@ impl BucketEntryInner {
return self.needs_constant_ping(cur_ts, KEEPALIVE_PING_INTERVAL_SECS as u64); return self.needs_constant_ping(cur_ts, KEEPALIVE_PING_INTERVAL_SECS as u64);
} }
// If we don't have node status for this node, then we should ping it to get some node status
for routing_domain in RoutingDomainSet::all() {
if self.has_node_info(routing_domain.into()) {
if self.node_status(routing_domain).is_none() {
return true;
}
}
}
match state { match state {
BucketEntryState::Reliable => { BucketEntryState::Reliable => {
// If we are in a reliable state, we need a ping on an exponential scale // If we are in a reliable state, we need a ping on an exponential scale
let latest_contact_time = self let latest_contact_time = self.latest_contact_time();
.peer_stats
.rpc_stats
.last_seen_ts
.max(self.peer_stats.rpc_stats.last_question);
match latest_contact_time { match latest_contact_time {
None => { None => {

View File

@ -435,9 +435,6 @@ impl RoutingTable {
// as we need to be able to use the relay for keepalives for all nat mappings // as we need to be able to use the relay for keepalives for all nat mappings
let mut low_level_protocol_ports = mapped_port_info.low_level_protocol_ports.clone(); let mut low_level_protocol_ports = mapped_port_info.low_level_protocol_ports.clone();
info!("outbound_dif: {:?}", outbound_dif);
info!("low_level_protocol_ports: {:?}", low_level_protocol_ports);
let can_serve_as_relay = e let can_serve_as_relay = e
.node_info(RoutingDomain::PublicInternet) .node_info(RoutingDomain::PublicInternet)
.map(|n| { .map(|n| {

View File

@ -8,7 +8,6 @@ impl RPCProcessor {
self, self,
peer: NodeRef, peer: NodeRef,
) -> Result<NetworkResult<Answer<SenderInfo>>, RPCError> { ) -> Result<NetworkResult<Answer<SenderInfo>>, RPCError> {
info!("ping to {:?}", peer);
let routing_domain = match peer.best_routing_domain() { let routing_domain = match peer.best_routing_domain() {
Some(rd) => rd, Some(rd) => rd,
None => { None => {
@ -44,7 +43,6 @@ impl RPCProcessor {
}, },
_ => return Err(RPCError::invalid_format("not an answer")), _ => return Err(RPCError::invalid_format("not an answer")),
}; };
info!("qwer");
// Ensure the returned node status is the kind for the routing domain we asked for // Ensure the returned node status is the kind for the routing domain we asked for
match routing_domain { match routing_domain {
@ -64,8 +62,6 @@ impl RPCProcessor {
} }
} }
info!("zxzxv");
// Update latest node status in routing table // Update latest node status in routing table
peer.update_node_status(status_a.node_status); peer.update_node_status(status_a.node_status);