graph/db: add versioned HasChannelEdge method
Add a new HasChannelEdge method that takes a gossip version parameter and returns only existence and zombie status, without timestamp data. This supports both v1 and v2 gossip protocols. The original HasChannelEdge method is renamed to HasV1ChannelEdge to preserve v1-specific functionality for callers that need timestamp information. All call sites are updated accordingly. The SQL store implementation now handles both gossip versions, using timestamps for v1 and block heights for v2 policies, with proper reject cache support for both versions.
This commit is contained in:
8 files changed
+258
-54
No files matched your search
+9
-7
@@ -1043,8 +1043,8 @@ func (b *Builder) addEdge(ctx context.Context, edge *models.ChannelEdgeInfo,
|
||||
|
||||
// Prior to processing the announcement we first check if we
|
||||
// already know of this channel, if so, then we can exit early.
|
||||
_, _, exists, isZombie, err := b.cfg.Graph.HasChannelEdge(
|
||||
edge.ChannelID,
|
||||
exists, isZombie, err := b.cfg.Graph.HasChannelEdge(
|
||||
edge.Version, edge.ChannelID,
|
||||
)
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||
return fmt.Errorf("unable to check for edge existence: %w",
|
||||
@@ -1145,7 +1145,7 @@ func (b *Builder) updateEdge(ctx context.Context,
|
||||
defer b.channelEdgeMtx.Unlock(policy.ChannelID)
|
||||
|
||||
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
||||
b.cfg.Graph.HasChannelEdge(policy.ChannelID)
|
||||
b.cfg.Graph.HasV1ChannelEdge(policy.ChannelID)
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
|
||||
return fmt.Errorf("unable to check for edge existence: %w", err)
|
||||
}
|
||||
@@ -1331,8 +1331,8 @@ func (b *Builder) IsPublicNode(node route.Vertex) (bool, error) {
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (b *Builder) IsKnownEdge(chanID lnwire.ShortChannelID) bool {
|
||||
_, _, exists, isZombie, _ := b.cfg.Graph.HasChannelEdge(
|
||||
chanID.ToUint64(),
|
||||
exists, isZombie, _ := b.cfg.Graph.HasChannelEdge(
|
||||
lnwire.GossipVersion1, chanID.ToUint64(),
|
||||
)
|
||||
|
||||
return exists || isZombie
|
||||
@@ -1343,7 +1343,9 @@ func (b *Builder) IsKnownEdge(chanID lnwire.ShortChannelID) bool {
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (b *Builder) IsZombieEdge(chanID lnwire.ShortChannelID) (bool, error) {
|
||||
_, _, _, isZombie, err := b.cfg.Graph.HasChannelEdge(chanID.ToUint64())
|
||||
_, isZombie, err := b.cfg.Graph.HasChannelEdge(
|
||||
lnwire.GossipVersion1, chanID.ToUint64(),
|
||||
)
|
||||
|
||||
return isZombie, err
|
||||
}
|
||||
@@ -1356,7 +1358,7 @@ func (b *Builder) IsStaleEdgePolicy(chanID lnwire.ShortChannelID,
|
||||
timestamp time.Time, flags lnwire.ChanUpdateChanFlags) bool {
|
||||
|
||||
edge1Timestamp, edge2Timestamp, exists, isZombie, err :=
|
||||
b.cfg.Graph.HasChannelEdge(chanID.ToUint64())
|
||||
b.cfg.Graph.HasV1ChannelEdge(chanID.ToUint64())
|
||||
if err != nil {
|
||||
log.Debugf("Check stale edge policy got error: %v", err)
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user