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