Skip to content

Commit 5531356

Browse files
committed
discovery: update UpdatesInHorizon
1 parent 5b484b8 commit 5531356

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

discovery/chan_series.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ type ChannelGraphTimeSeries interface {
3030
// update timestamp between the start time and end time. We'll use this
3131
// to catch up a remote node to the set of channel updates that they
3232
// may have missed out on within the target chain.
33-
UpdatesInHorizon(chain chainhash.Hash,
34-
startTime time.Time, endTime time.Time) ([]lnwire.Message, error)
33+
UpdatesInHorizon(chain chainhash.Hash, startTime time.Time,
34+
endTime time.Time, startBlock,
35+
endBlock uint32) ([]lnwire.Message, error)
3536

3637
// FilterKnownChanIDs takes a target chain, and a set of channel ID's,
3738
// and returns a filtered set of chan ID's. This filtered set of chan
@@ -103,15 +104,16 @@ func (c *ChanSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID
103104
// within the target chain.
104105
//
105106
// NOTE: This is part of the ChannelGraphTimeSeries interface.
106-
func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
107-
startTime time.Time, endTime time.Time) ([]lnwire.Message, error) {
107+
func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash, startTime time.Time,
108+
endTime time.Time, startBlock, endBlock uint32) ([]lnwire.Message,
109+
error) {
108110

109111
var updates []lnwire.Message
110112

111113
// First, we'll query for all the set of channels that have an update
112114
// that falls within the specified horizon.
113115
chansInHorizon, err := c.graph.ChanUpdatesInHorizon(
114-
startTime, endTime, 0, 0,
116+
startTime, endTime, startBlock, endBlock,
115117
)
116118
if err != nil {
117119
return nil, err

discovery/syncer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,9 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
11941194
time.Duration(g.remoteUpdateHorizon.TimestampRange) * time.Second,
11951195
)
11961196

1197+
startBlock := g.remoteUpdateHorizon.FirstBlockHeight.UnwrapOr(0)
1198+
endBlock := g.remoteUpdateHorizon.BlockRange.UnwrapOr(0)
1199+
11971200
g.Unlock()
11981201

11991202
// If requested, don't reply with historical gossip data when the remote
@@ -1205,7 +1208,7 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
12051208
// Now that the remote peer has applied their filter, we'll query the
12061209
// database for all the messages that are beyond this filter.
12071210
newUpdatestoSend, err := g.cfg.channelSeries.UpdatesInHorizon(
1208-
g.cfg.chainHash, startTime, endTime,
1211+
g.cfg.chainHash, startTime, endTime, startBlock, endBlock,
12091212
)
12101213
if err != nil {
12111214
return err

discovery/syncer_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ var (
2828
)
2929

3030
type horizonQuery struct {
31-
chain chainhash.Hash
32-
start time.Time
33-
end time.Time
31+
chain chainhash.Hash
32+
start time.Time
33+
end time.Time
34+
startBlock uint32
35+
endBlock uint32
3436
}
37+
3538
type filterRangeReq struct {
3639
startHeight, endHeight uint32
3740
}
@@ -82,10 +85,11 @@ func (m *mockChannelGraphTimeSeries) HighestChanID(chain chainhash.Hash) (*lnwir
8285
return &m.highestID, nil
8386
}
8487
func (m *mockChannelGraphTimeSeries) UpdatesInHorizon(chain chainhash.Hash,
85-
startTime time.Time, endTime time.Time) ([]lnwire.Message, error) {
88+
startTime time.Time, endTime time.Time, startBlock, endBlock uint32) (
89+
[]lnwire.Message, error) {
8690

8791
m.horizonReq <- horizonQuery{
88-
chain, startTime, endTime,
92+
chain, startTime, endTime, startBlock, endBlock,
8993
}
9094

9195
return <-m.horizonResp, nil

0 commit comments

Comments
 (0)