Skip to content

Commit 332cad3

Browse files
committed
discovery: update UpdatesInHorizon
1 parent c248f60 commit 332cad3

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

discovery/chan_series.go

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

3535
// FilterKnownChanIDs takes a target chain, and a set of channel ID's,
3636
// and returns a filtered set of chan ID's. This filtered set of chan
@@ -104,15 +104,15 @@ func (c *ChanSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID
104104
// within the target chain.
105105
//
106106
// NOTE: This is part of the ChannelGraphTimeSeries interface.
107-
func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
108-
startTime time.Time, endTime time.Time) ([]lnwire.Message, error) {
107+
func (c *ChanSeries) UpdatesInHorizon(startTime, endTime time.Time, startBlock,
108+
endBlock uint32) ([]lnwire.Message, error) {
109109

110110
var updates []lnwire.Message
111111

112112
// First, we'll query for all the set of channels that have an update
113113
// that falls within the specified horizon.
114114
chansInHorizon, err := c.graph.ChanUpdatesInHorizon(
115-
startTime, endTime, 0, 0,
115+
startTime, endTime, startBlock, endBlock,
116116
)
117117
if err != nil {
118118
return nil, err

discovery/syncer.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,13 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
13191319
time.Duration(g.remoteUpdateHorizon.TimestampRange) * time.Second,
13201320
)
13211321

1322+
var (
1323+
startBlock = tlv.ZeroRecordT[tlv.TlvType2, uint32]()
1324+
endBlock = tlv.ZeroRecordT[tlv.TlvType4, uint32]()
1325+
)
1326+
startBlock = g.remoteUpdateHorizon.FirstBlockHeight.UnwrapOr(startBlock)
1327+
endBlock = g.remoteUpdateHorizon.BlockRange.UnwrapOr(endBlock)
1328+
13221329
g.Unlock()
13231330

13241331
// If requested, don't reply with historical gossip data when the remote
@@ -1342,7 +1349,7 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
13421349
// Now that the remote peer has applied their filter, we'll query the
13431350
// database for all the messages that are beyond this filter.
13441351
newUpdatestoSend, err := g.cfg.channelSeries.UpdatesInHorizon(
1345-
g.cfg.chainHash, startTime, endTime,
1352+
startTime, endTime, startBlock.Val, endBlock.Val,
13461353
)
13471354
if err != nil {
13481355
returnSema()

discovery/syncer_test.go

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

3030
type horizonQuery struct {
31-
chain chainhash.Hash
32-
start time.Time
33-
end time.Time
31+
start time.Time
32+
end time.Time
33+
startBlock uint32
34+
endBlock uint32
3435
}
36+
3537
type filterRangeReq struct {
3638
startHeight, endHeight uint32
3739
}
@@ -81,11 +83,12 @@ func newMockChannelGraphTimeSeries(
8183
func (m *mockChannelGraphTimeSeries) HighestChanID(chain chainhash.Hash) (*lnwire.ShortChannelID, error) {
8284
return &m.highestID, nil
8385
}
84-
func (m *mockChannelGraphTimeSeries) UpdatesInHorizon(chain chainhash.Hash,
85-
startTime time.Time, endTime time.Time) ([]lnwire.Message, error) {
86+
func (m *mockChannelGraphTimeSeries) UpdatesInHorizon(startTime time.Time,
87+
endTime time.Time, startBlock, endBlock uint32) ([]lnwire.Message,
88+
error) {
8689

8790
m.horizonReq <- horizonQuery{
88-
chain, startTime, endTime,
91+
startTime, endTime, startBlock, endBlock,
8992
}
9093

9194
return <-m.horizonResp, nil

0 commit comments

Comments
 (0)