discovery: use inclusive range in FilterChannelRange

FilterChannelRange takes an inclusive range, so it was possible for us
to return channels for an additional block that was not requested.
This commit is contained in:
Wilmer Paulino 2019-12-13 16:07:53 -08:00
parent 66ff2c1e7a
commit 1f781ea431
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F
2 changed files with 11 additions and 5 deletions

View File

@ -814,8 +814,9 @@ func (g *GossipSyncer) replyChanRangeQuery(query *lnwire.QueryChannelRange) erro
// Next, we'll consult the time series to obtain the set of known
// channel ID's that match their query.
startBlock := query.FirstBlockHeight
endBlock := startBlock + query.NumBlocks - 1
channelRange, err := g.cfg.channelSeries.FilterChannelRange(
query.ChainHash, startBlock, startBlock+query.NumBlocks,
query.ChainHash, startBlock, endBlock,
)
if err != nil {
return err

View File

@ -709,10 +709,12 @@ func TestGossipSyncerReplyChanRangeQuery(t *testing.T) {
// Next, we'll craft a query to ask for all the new chan ID's after
// block 100.
const startingBlockHeight int = 100
const startingBlockHeight = 100
const numBlocks = 50
const endingBlockHeight = startingBlockHeight + numBlocks - 1
query := &lnwire.QueryChannelRange{
FirstBlockHeight: uint32(startingBlockHeight),
NumBlocks: 50,
NumBlocks: uint32(numBlocks),
}
// We'll then launch a goroutine to reply to the query with a set of 5
@ -744,8 +746,11 @@ func TestGossipSyncerReplyChanRangeQuery(t *testing.T) {
return
case filterReq := <-chanSeries.filterRangeReqs:
// We should be querying for block 100 to 150.
if filterReq.startHeight != 100 && filterReq.endHeight != 150 {
errCh <- fmt.Errorf("wrong height range: %v", spew.Sdump(filterReq))
if filterReq.startHeight != startingBlockHeight &&
filterReq.endHeight != endingBlockHeight {
errCh <- fmt.Errorf("wrong height range: %v",
spew.Sdump(filterReq))
return
}