Skip to content

Commit 249cf2c

Browse files
committed
Explicitly specify default sync behavior for no-std
1 parent 10f2c67 commit 249cf2c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,24 +1730,27 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
17301730
return Err(PeerHandleError { }.into());
17311731
}
17321732

1733-
if let wire::Message::GossipTimestampFilter(msg) = message {
1733+
if let wire::Message::GossipTimestampFilter(_msg) = message {
17341734
// When supporting gossip messages, start initial gossip sync only after we receive
17351735
// a GossipTimestampFilter
17361736

17371737
if peer_lock.their_features.as_ref().unwrap().supports_gossip_queries() &&
17381738
!peer_lock.sent_gossip_timestamp_filter {
17391739
peer_lock.sent_gossip_timestamp_filter = true;
17401740

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

0 commit comments

Comments
 (0)