graphdb: pass context to FilterKnownChanIDs

This commit is contained in:
Elle Mouton committed 2026-02-25 16:11:46 +02:00
1 parent 46d37a691f
commit 072244ee18
6 files changed
+21 -16

No files matched your search

+3 -1
View File
@@ -215,7 +215,9 @@ func (c *ChanSeries) FilterKnownChanIDs(_ chainhash.Hash,
isZombieChan func(time.Time, time.Time) bool) (
[]lnwire.ShortChannelID, error) {
newChanIDs, err := c.graph.FilterKnownChanIDs(superSet, isZombieChan)
newChanIDs, err := c.graph.FilterKnownChanIDs(
context.TODO(), superSet, isZombieChan,
)
if err != nil {
return nil, err
}
+4 -3
View File
@@ -514,10 +514,11 @@ func (c *ChannelGraph) PruneGraphNodes() error {
// words, we perform a set difference of our set of chan ID's and the ones
// passed in. This method can be used by callers to determine the set of
// channels another peer knows of that we don't.
func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
func (c *ChannelGraph) FilterKnownChanIDs(ctx context.Context,
chansInfo []ChannelUpdateInfo,
isZombieChan func(time.Time, time.Time) bool) ([]uint64, error) {
unknown, knownZombies, err := c.db.FilterKnownChanIDs(chansInfo)
unknown, knownZombies, err := c.db.FilterKnownChanIDs(ctx, chansInfo)
if err != nil {
return nil, err
}
@@ -547,7 +548,7 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo,
// alive, and we let it be added to the set of IDs to query our
// peer for.
err := c.db.MarkEdgeLive(
context.TODO(), info.ShortChannelID.ToUint64(),
ctx, info.ShortChannelID.ToUint64(),
)
// Since there is a chance that the edge could have been marked
// as "live" between the FilterKnownChanIDs call and the
+7 -5
View File
@@ -2976,7 +2976,7 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
// Call FilterKnownChanIDs with an isStillZombie call-back that would
// result in the current zombies still be considered as zombies.
_, err = graph.FilterKnownChanIDs([]ChannelUpdateInfo{
_, err = graph.FilterKnownChanIDs(ctx, []ChannelUpdateInfo{
{ShortChannelID: scid1},
{ShortChannelID: scid2},
{ShortChannelID: scid3},
@@ -2992,7 +2992,7 @@ func TestFilterKnownChanIDsZombieRevival(t *testing.T) {
// Now call it again but this time with a isStillZombie call-back that
// would result in channel with SCID 2 no longer being considered a
// zombie.
_, err = graph.FilterKnownChanIDs([]ChannelUpdateInfo{
_, err = graph.FilterKnownChanIDs(ctx, []ChannelUpdateInfo{
{ShortChannelID: scid1},
{
ShortChannelID: scid2,
@@ -3038,7 +3038,9 @@ func TestFilterKnownChanIDs(t *testing.T) {
{ShortChannelID: scid2},
{ShortChannelID: scid3},
}
filteredIDs, err := graph.FilterKnownChanIDs(preChanIDs, isZombieUpdate)
filteredIDs, err := graph.FilterKnownChanIDs(
ctx, preChanIDs, isZombieUpdate,
)
require.NoError(t, err, "unable to filter chan IDs")
require.EqualValues(t, []uint64{
scid1.ToUint64(),
@@ -3163,7 +3165,7 @@ func TestFilterKnownChanIDs(t *testing.T) {
for _, queryCase := range queryCases {
resp, err := graph.FilterKnownChanIDs(
queryCase.queryIDs, isZombieUpdate,
ctx, queryCase.queryIDs, isZombieUpdate,
)
require.NoError(t, err)
@@ -3342,7 +3344,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
}
_, err := graph.FilterKnownChanIDs(
chanIDs,
ctx, chanIDs,
func(t time.Time, t2 time.Time) bool {
return rand.Intn(2) == 0
},
+3 -2
View File
@@ -267,8 +267,9 @@ type Store interface { //nolint:interfacebloat
// callers to determine the set of channels another peer knows of that
// we don't. The ChannelUpdateInfos for the known zombies is also
// returned.
FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64,
[]ChannelUpdateInfo, error)
FilterKnownChanIDs(ctx context.Context,
chansInfo []ChannelUpdateInfo) ([]uint64, []ChannelUpdateInfo,
error)
// FilterChannelRange returns the channel ID's of all known channels
// which were mined in a block height within the passed range. The
+2 -2
View File
@@ -2679,8 +2679,8 @@ func (c *KVStore) NodeUpdatesInHorizon(_ context.Context, startTime,
// passed in. This method can be used by callers to determine the set of
// channels another peer knows of that we don't. The ChannelUpdateInfos for the
// known zombies is also returned.
func (c *KVStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64,
[]ChannelUpdateInfo, error) {
func (c *KVStore) FilterKnownChanIDs(_ context.Context,
chansInfo []ChannelUpdateInfo) ([]uint64, []ChannelUpdateInfo, error) {
var (
newChanIDs []uint64
+2 -3
View File
@@ -2679,11 +2679,10 @@ func (s *SQLStore) forEachChanWithPoliciesInSCIDList(ctx context.Context,
// known zombies is also returned.
//
// NOTE: part of the Store interface.
func (s *SQLStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64,
[]ChannelUpdateInfo, error) {
func (s *SQLStore) FilterKnownChanIDs(ctx context.Context,
chansInfo []ChannelUpdateInfo) ([]uint64, []ChannelUpdateInfo, error) {
var (
ctx = context.TODO()
newChanIDs []uint64
knownZombies []ChannelUpdateInfo
infoLookup = make(