graphdb: pass context to HasV1ChannelEdge
This commit is contained in:
5 files changed
+15
-13
No files matched your search
+4
-2
@@ -1151,7 +1151,7 @@ func (b *Builder) updateEdge(ctx context.Context,
|
|||||||
defer b.channelEdgeMtx.Unlock(policy.ChannelID)
|
defer b.channelEdgeMtx.Unlock(policy.ChannelID)
|
||||||
|
|
||||||
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
||||||
b.cfg.Graph.HasV1ChannelEdge(policy.ChannelID)
|
b.cfg.Graph.HasV1ChannelEdge(ctx, policy.ChannelID)
|
||||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||||
return fmt.Errorf("unable to check for edge existence: %w", err)
|
return fmt.Errorf("unable to check for edge existence: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1366,7 +1366,9 @@ func (b *Builder) IsStaleEdgePolicy(chanID lnwire.ShortChannelID,
|
|||||||
timestamp time.Time, flags lnwire.ChanUpdateChanFlags) bool {
|
timestamp time.Time, flags lnwire.ChanUpdateChanFlags) bool {
|
||||||
|
|
||||||
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
||||||
b.cfg.Graph.HasV1ChannelEdge(chanID.ToUint64())
|
b.cfg.Graph.HasV1ChannelEdge(
|
||||||
|
context.TODO(), chanID.ToUint64(),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("Check stale edge policy got error: %v", err)
|
log.Debugf("Check stale edge policy got error: %v", err)
|
||||||
return false
|
return false
|
||||||
|
|||||||
+3
-3
@@ -674,10 +674,10 @@ func (c *ChannelGraph) DisabledChannelIDs(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HasV1ChannelEdge returns true if the database knows of a channel edge.
|
// HasV1ChannelEdge returns true if the database knows of a channel edge.
|
||||||
func (c *ChannelGraph) HasV1ChannelEdge(chanID uint64) (time.Time,
|
func (c *ChannelGraph) HasV1ChannelEdge(ctx context.Context,
|
||||||
time.Time, bool, bool, error) {
|
chanID uint64) (time.Time, time.Time, bool, bool, error) {
|
||||||
|
|
||||||
return c.db.HasV1ChannelEdge(chanID)
|
return c.db.HasV1ChannelEdge(ctx, chanID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasChannelEdge returns true if the database knows of a channel edge.
|
// HasChannelEdge returns true if the database knows of a channel edge.
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ type Store interface { //nolint:interfacebloat
|
|||||||
// last time the edge was updated for both directed edges are returned
|
// last time the edge was updated for both directed edges are returned
|
||||||
// along with the boolean. If it is not found, then the zombie index is
|
// along with the boolean. If it is not found, then the zombie index is
|
||||||
// checked and its result is returned as the second boolean.
|
// checked and its result is returned as the second boolean.
|
||||||
HasV1ChannelEdge(chanID uint64) (time.Time, time.Time, bool, bool,
|
HasV1ChannelEdge(ctx context.Context, chanID uint64) (
|
||||||
error)
|
time.Time, time.Time, bool, bool, error)
|
||||||
|
|
||||||
// HasChannelEdge returns true if the database knows of a channel edge
|
// HasChannelEdge returns true if the database knows of a channel edge
|
||||||
// with the passed channel ID and gossip version, and false otherwise.
|
// with the passed channel ID and gossip version, and false otherwise.
|
||||||
|
|||||||
@@ -1318,7 +1318,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
|
|||||||
// the edge was updated for both directed edges are returned along with the
|
// the edge was updated for both directed edges are returned along with the
|
||||||
// boolean. If it is not found, then the zombie index is checked and its
|
// boolean. If it is not found, then the zombie index is checked and its
|
||||||
// result is returned as the second boolean.
|
// result is returned as the second boolean.
|
||||||
func (c *KVStore) HasV1ChannelEdge(
|
func (c *KVStore) HasV1ChannelEdge(_ context.Context,
|
||||||
chanID uint64) (time.Time, time.Time, bool, bool, error) {
|
chanID uint64) (time.Time, time.Time, bool, bool, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -1434,7 +1434,9 @@ func (c *KVStore) HasChannelEdge(v lnwire.GossipVersion,
|
|||||||
return false, false, ErrVersionNotSupportedForKVDB
|
return false, false, ErrVersionNotSupportedForKVDB
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, exists, isZombie, err := c.HasV1ChannelEdge(chanID)
|
_, _, exists, isZombie, err := c.HasV1ChannelEdge(
|
||||||
|
context.TODO(), chanID,
|
||||||
|
)
|
||||||
|
|
||||||
return exists, isZombie, err
|
return exists, isZombie, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2244,10 +2244,8 @@ func (s *SQLStore) FetchChannelEdgesByOutpoint(ctx context.Context,
|
|||||||
// result is returned as the second boolean.
|
// result is returned as the second boolean.
|
||||||
//
|
//
|
||||||
// NOTE: part of the Store interface.
|
// NOTE: part of the Store interface.
|
||||||
func (s *SQLStore) HasV1ChannelEdge(chanID uint64) (time.Time, time.Time, bool,
|
func (s *SQLStore) HasV1ChannelEdge(ctx context.Context,
|
||||||
bool, error) {
|
chanID uint64) (time.Time, time.Time, bool, bool, error) {
|
||||||
|
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
exists bool
|
exists bool
|
||||||
|
|||||||
Reference in new issue
Block a user