Compare commits

..

1 Commits

Author SHA1 Message Date
0g-peterzhb
a6d9d80cf5
Merge f456773b72 into 12d0c6b675 2024-08-14 11:36:11 +08:00
3 changed files with 15 additions and 20 deletions

View File

@ -26,10 +26,10 @@ use crate::peer_manager::PeerManager;
use crate::Config; use crate::Config;
lazy_static::lazy_static! { lazy_static::lazy_static! {
pub static ref FIND_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(5); pub static ref FIND_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(2);
pub static ref ANNOUNCE_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(5); pub static ref ANNOUNCE_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(2);
pub static ref ANNOUNCE_SHARD_CONFIG_TIMEOUT: chrono::Duration = chrono::Duration::minutes(5); pub static ref ANNOUNCE_SHARD_CONFIG_TIMEOUT: chrono::Duration = chrono::Duration::minutes(2);
pub static ref TOLERABLE_DRIFT: chrono::Duration = chrono::Duration::seconds(10); pub static ref TOLERABLE_DRIFT: chrono::Duration = chrono::Duration::seconds(5);
} }
#[allow(deprecated)] #[allow(deprecated)]
@ -403,7 +403,7 @@ impl Libp2pEventHandler {
// verify timestamp // verify timestamp
let d = duration_since(timestamp); let d = duration_since(timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT { if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT {
debug!(%timestamp, ?d, "Invalid timestamp, ignoring FindFile message"); debug!(%timestamp, "Invalid timestamp, ignoring FindFile message");
return MessageAcceptance::Ignore; return MessageAcceptance::Ignore;
} }
@ -481,7 +481,7 @@ impl Libp2pEventHandler {
// verify timestamp // verify timestamp
let d = duration_since(msg.timestamp); let d = duration_since(msg.timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT { if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT {
debug!(%msg.timestamp, ?d, "Invalid timestamp, ignoring FindFile message"); debug!(%msg.timestamp, "Invalid timestamp, ignoring FindFile message");
return MessageAcceptance::Ignore; return MessageAcceptance::Ignore;
} }
@ -550,8 +550,7 @@ impl Libp2pEventHandler {
let seen_ips: Vec<IpAddr> = match self.network_globals.peers.read().peer_info(peer_id) { let seen_ips: Vec<IpAddr> = match self.network_globals.peers.read().peer_info(peer_id) {
Some(v) => v.seen_ip_addresses().collect(), Some(v) => v.seen_ip_addresses().collect(),
None => { None => {
// ignore file announcement from un-seen peers debug!(%announced_ip, "Failed to verify announced IP address, no peer info found");
trace!(%announced_ip, "Failed to verify announced IP address, no peer info found");
return false; return false;
} }
}; };
@ -559,8 +558,7 @@ impl Libp2pEventHandler {
if seen_ips.iter().any(|x| *x == announced_ip) { if seen_ips.iter().any(|x| *x == announced_ip) {
true true
} else { } else {
// ignore file announcement if announced IP and seen IP mismatch debug!(%announced_ip, ?seen_ips, "Failed to verify announced IP address, mismatch with seen ips");
trace!(%announced_ip, ?seen_ips, "Failed to verify announced IP address, mismatch with seen ips");
false false
} }
} }
@ -589,7 +587,7 @@ impl Libp2pEventHandler {
// propagate gossip to peers // propagate gossip to peers
let d = duration_since(msg.resend_timestamp); let d = duration_since(msg.resend_timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_FILE_TIMEOUT { if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_FILE_TIMEOUT {
debug!(%msg.resend_timestamp, ?d, "Invalid resend timestamp, ignoring AnnounceFile message"); debug!(%msg.resend_timestamp, "Invalid resend timestamp, ignoring AnnounceFile message");
return MessageAcceptance::Ignore; return MessageAcceptance::Ignore;
} }
@ -630,7 +628,7 @@ impl Libp2pEventHandler {
// propagate gossip to peers // propagate gossip to peers
let d = duration_since(msg.resend_timestamp); let d = duration_since(msg.resend_timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_SHARD_CONFIG_TIMEOUT { if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_SHARD_CONFIG_TIMEOUT {
debug!(%msg.resend_timestamp, ?d, "Invalid resend timestamp, ignoring AnnounceShardConfig message"); debug!(%msg.resend_timestamp, "Invalid resend timestamp, ignoring AnnounceShardConfig message");
return MessageAcceptance::Ignore; return MessageAcceptance::Ignore;
} }
@ -676,7 +674,7 @@ impl Libp2pEventHandler {
// propagate gossip to peers // propagate gossip to peers
let d = duration_since(msg.resend_timestamp); let d = duration_since(msg.resend_timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_FILE_TIMEOUT { if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_FILE_TIMEOUT {
debug!(%msg.resend_timestamp, ?d, "Invalid resend timestamp, ignoring AnnounceChunks message"); debug!(%msg.resend_timestamp, "Invalid resend timestamp, ignoring AnnounceChunks message");
return MessageAcceptance::Ignore; return MessageAcceptance::Ignore;
} }

View File

@ -749,7 +749,7 @@ impl SyncService {
to_terminate.push(*tx_seq); to_terminate.push(*tx_seq);
} }
} }
} else if self.controllers.contains_key(&min_tx_seq) { } else {
to_terminate.push(min_tx_seq); to_terminate.push(min_tx_seq);
} }
@ -757,12 +757,9 @@ impl SyncService {
self.controllers.remove(tx_seq); self.controllers.remove(tx_seq);
} }
let num_terminated = to_terminate.len();
if num_terminated > 0 {
debug!(?to_terminate, "File sync terminated"); debug!(?to_terminate, "File sync terminated");
}
num_terminated to_terminate.len()
} }
fn on_heartbeat(&mut self) { fn on_heartbeat(&mut self) {

View File

@ -1 +1 @@
debug,hyper=info,h2=info,rpc=info,discv5=info,jsonrpsee_http_server=info debug,hyper=info,h2=info,rpc=info,discv5=info,router=info,jsonrpsee_http_server=info