Skip to content

Commit

Permalink
Explicitly specify default sync behavior for no-std
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Dec 5, 2024
1 parent 7353cec commit e582222
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,23 +1730,26 @@ 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
if peer_lock.their_features.as_ref().unwrap().supports_gossip_queries() &&
!peer_lock.sent_gossip_timestamp_filter {
peer_lock.sent_gossip_timestamp_filter = true;

#[allow(unused_mut, unused_assignments)]
let mut full_sync_threshold = 0;
#[allow(unused_mut)]
let mut should_do_full_sync = true;
#[cfg(feature = "std")]
{
// if the timestamp range starts more than six hours ago, do a full sync
// otherwise, start at the current time
// otherwise, only forward ad-hoc gossip
use std::time::{SystemTime, UNIX_EPOCH};
full_sync_threshold = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time must be > 1970").as_secs() - 6 * 3600;
let full_sync_threshold = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time must be > 1970").as_secs() - 6 * 3600;
if (_msg.first_timestamp as u64) > full_sync_threshold {
should_do_full_sync = false;
}
}
if (msg.first_timestamp as u64) <= full_sync_threshold {
if should_do_full_sync {
peer_lock.sync_status = InitSyncTracker::ChannelsSyncing(0);
}
}
Expand Down

0 comments on commit e582222

Please sign in to comment.