Skip to content

Commit

Permalink
f: Move threshold check inside filter verification check
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Nov 21, 2024
1 parent 3854be0 commit e5f9a11
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1725,22 +1725,22 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
// When supporting gossip messages, start initial gossip sync only after we receive
// a GossipTimestampFilter

#[allow(unused_mut, unused_assignments)]
let mut full_sync_threshold = 0;
#[cfg(feature = "std")]
{
// if the timestamp range starts more than an hour ago, do a fully sync
// otherwise, start at the current time
use std::time::{SystemTime, UNIX_EPOCH};
full_sync_threshold = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time must be > 1970").as_secs() - 3600;
}

if peer_lock.their_features.as_ref().unwrap().supports_gossip_queries() &&
!peer_lock.sent_gossip_timestamp_filter &&
(msg.first_timestamp as u64) <= full_sync_threshold
{
!peer_lock.sent_gossip_timestamp_filter {
peer_lock.sent_gossip_timestamp_filter = true;
peer_lock.sync_status = InitSyncTracker::ChannelsSyncing(0);

#[allow(unused_mut, unused_assignments)]
let mut full_sync_threshold = 0;
#[cfg(feature = "std")]
{
// if the timestamp range starts more than an hour ago, do a full sync
// otherwise, start at the current time
use std::time::{SystemTime, UNIX_EPOCH};
full_sync_threshold = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time must be > 1970").as_secs() - 3600;
}
if (msg.first_timestamp as u64) <= full_sync_threshold {
peer_lock.sync_status = InitSyncTracker::ChannelsSyncing(0);
}
}
return Ok(None);
}
Expand Down

0 comments on commit e5f9a11

Please sign in to comment.