Skip to content
Permalink
Browse files

discovery: make timestamp range check inclusive within FilterGossipMsgs

As required by the spec:

> SHOULD send all gossip messages whose timestamp is greater or equal to
first_timestamp, and less than first_timestamp plus timestamp_range.
  • Loading branch information...
wpaulino committed Mar 21, 2019
1 parent 7390dca commit 23aa6f2ae04a8047c9e2a9594f673230a71741b5
Showing with 14 additions and 1 deletion.
  1. +14 −1 discovery/syncer.go
@@ -950,7 +950,8 @@ func (g *gossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {

passesFilter := func(timeStamp uint32) bool {
t := time.Unix(int64(timeStamp), 0)
return t.After(startTime) && t.Before(endTime)
return t.Equal(startTime) ||
(t.After(startTime) && t.Before(endTime))
}

msgsToSend := make([]lnwire.Message, 0, len(msgs))
@@ -989,6 +990,12 @@ func (g *gossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
if passesFilter(chanUpdate.Timestamp) {
msgsToSend = append(msgsToSend, msg)
break
} else {
log.Debugf("ChannelUpdate message with "+
"timestamp=%v did not pass filter in "+
"range start_timestamp=%v, "+
"end_timestamp=%v", chanUpdate.Timestamp,
startTime, endTime)
}
}

@@ -1001,6 +1008,12 @@ func (g *gossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
case *lnwire.ChannelUpdate:
if passesFilter(msg.Timestamp) {
msgsToSend = append(msgsToSend, msg)
} else {
log.Debugf("ChannelUpdate message with "+
"timestamp=%v did not pass filter in "+
"range start_timestamp=%v, "+
"end_timestamp=%v", msg.Timestamp,
startTime, endTime)
}

// Similarly, we only send node announcements if the update

0 comments on commit 23aa6f2

Please sign in to comment.
You can’t perform that action at this time.