Skip to content

Commit 49fe20c

Browse files
committed
discovery: update UpdatesInHorizon
1 parent 146fc9e commit 49fe20c

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

discovery/chan_series.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ 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(startTime time.Time, endTime time.Time, startBlock,
34+
endBlock uint32) ([]lnwire.Message, error)
3535

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

111111
var updates []lnwire.Message
112112

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

discovery/syncer.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,13 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
12881288
time.Duration(g.remoteUpdateHorizon.TimestampRange) * time.Second,
12891289
)
12901290

1291+
var (
1292+
startBlock = tlv.ZeroRecordT[tlv.TlvType2, uint32]()
1293+
endBlock = tlv.ZeroRecordT[tlv.TlvType4, uint32]()
1294+
)
1295+
startBlock = g.remoteUpdateHorizon.FirstBlockHeight.UnwrapOr(startBlock)
1296+
endBlock = g.remoteUpdateHorizon.BlockRange.UnwrapOr(endBlock)
1297+
12911298
g.Unlock()
12921299

12931300
// If requested, don't reply with historical gossip data when the remote
@@ -1299,7 +1306,7 @@ func (g *GossipSyncer) ApplyGossipFilter(filter *lnwire.GossipTimestampRange) er
12991306
// Now that the remote peer has applied their filter, we'll query the
13001307
// database for all the messages that are beyond this filter.
13011308
newUpdatestoSend, err := g.cfg.channelSeries.UpdatesInHorizon(
1302-
g.cfg.chainHash, startTime, endTime,
1309+
startTime, endTime, startBlock.Val, endBlock.Val,
13031310
)
13041311
if err != nil {
13051312
return err

discovery/syncer_test.go

+9-6
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)