Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gossip filtration fix #3390

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,11 +1721,24 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
return Err(PeerHandleError { }.into());
}

if let wire::Message::GossipTimestampFilter(_msg) = message {
if let wire::Message::GossipTimestampFilter(msg) = message {
// 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
arik-so marked this conversation as resolved.
Show resolved Hide resolved
// 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 {
!peer_lock.sent_gossip_timestamp_filter &&
(msg.first_timestamp as u64) <= full_sync_threshold
{
peer_lock.sent_gossip_timestamp_filter = true;
peer_lock.sync_status = InitSyncTracker::ChannelsSyncing(0);
}
Expand Down
Loading