routing/chainview: if the chain filter is empty, don't fetch the cfilter
This commit is contained in:
parent
885cc6b216
commit
0c134a8cb3
@ -250,12 +250,21 @@ func (c *CfFilteredChainView) FilterBlock(blockHash *chainhash.Hash) (*FilteredB
|
|||||||
Height: blockHeight,
|
Height: blockHeight,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we don't have any items within our current chain filter, then we
|
||||||
|
// can exit early as we don't need to fetch the filter.
|
||||||
|
c.filterMtx.RLock()
|
||||||
|
numPoints := len(c.chainFilter)
|
||||||
|
c.filterMtx.RUnlock()
|
||||||
|
if numPoints == 0 {
|
||||||
|
return filteredBlock, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Next, using the block, hash, we'll fetch the compact filter for this
|
// Next, using the block, hash, we'll fetch the compact filter for this
|
||||||
// block. We only require the regular filter as we're just looking for
|
// block. We only require the regular filter as we're just looking for
|
||||||
// outpoint that have been spent.
|
// outpoint that have been spent.
|
||||||
filter, err := c.p2pNode.GetCFilter(*blockHash, false)
|
filter, err := c.p2pNode.GetCFilter(*blockHash, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return filteredBlock, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before we can match the filter, we'll need to map each item in our
|
// Before we can match the filter, we'll need to map each item in our
|
||||||
|
Loading…
Reference in New Issue
Block a user