graphdb: pass context to FilterKnownChanIDs
This commit is contained in:
6 files changed
+21
-16
No files matched your search
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user