Skip to content

Commit 3854be0

Browse files
committed
Trigger full sync on old GossipTimestampFilter
1 parent 8da30df commit 3854be0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,11 +1721,24 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
17211721
return Err(PeerHandleError { }.into());
17221722
}
17231723

1724-
if let wire::Message::GossipTimestampFilter(_msg) = message {
1724+
if let wire::Message::GossipTimestampFilter(msg) = message {
17251725
// When supporting gossip messages, start initial gossip sync only after we receive
17261726
// a GossipTimestampFilter
1727+
1728+
#[allow(unused_mut, unused_assignments)]
1729+
let mut full_sync_threshold = 0;
1730+
#[cfg(feature = "std")]
1731+
{
1732+
// if the timestamp range starts more than an hour ago, do a fully sync
1733+
// otherwise, start at the current time
1734+
use std::time::{SystemTime, UNIX_EPOCH};
1735+
full_sync_threshold = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time must be > 1970").as_secs() - 3600;
1736+
}
1737+
17271738
if peer_lock.their_features.as_ref().unwrap().supports_gossip_queries() &&
1728-
!peer_lock.sent_gossip_timestamp_filter {
1739+
!peer_lock.sent_gossip_timestamp_filter &&
1740+
(msg.first_timestamp as u64) <= full_sync_threshold
1741+
{
17291742
peer_lock.sent_gossip_timestamp_filter = true;
17301743
peer_lock.sync_status = InitSyncTracker::ChannelsSyncing(0);
17311744
}

0 commit comments

Comments
 (0)