graph/db: remove unused sig field from ChannelEdgePolicy

Remove the cached parsed signature field and its lazy getter method
from ChannelEdgePolicy. This field was unused throughout the codebase
and the signature is already stored as raw bytes in SigBytes.

The SetSigBytes method is updated to remove the cache invalidation
logic.
This commit is contained in:
Elle Mouton committed 2026-02-13 07:21:21 +02:00
1 parent fcbfeb33e0
commit 6fda2e8da9
2 files changed
+2 -34

No files matched your search

+1 -33
View File
@@ -4,7 +4,6 @@ import (
"fmt"
"time"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/lnwire"
)
@@ -17,13 +16,9 @@ import (
type ChannelEdgePolicy struct {
// SigBytes is the raw bytes of the signature of the channel edge
// policy. We'll only parse these if the caller needs to access the
// signature for validation purposes. Do not set SigBytes directly, but
// use SetSigBytes instead to make sure that the cache is invalidated.
// signature for validation purposes.
SigBytes []byte
// sig is a cached fully parsed signature.
sig *ecdsa.Signature
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
@@ -84,33 +79,6 @@ type ChannelEdgePolicy struct {
ExtraOpaqueData lnwire.ExtraOpaqueData
}
// Signature is a channel announcement signature, which is needed for proper
// edge policy announcement.
//
// NOTE: By having this method to access an attribute, we ensure we only need
// to fully deserialize the signature if absolutely necessary.
func (c *ChannelEdgePolicy) Signature() (*ecdsa.Signature, error) {
if c.sig != nil {
return c.sig, nil
}
sig, err := ecdsa.ParseSignature(c.SigBytes)
if err != nil {
return nil, err
}
c.sig = sig
return sig, nil
}
// SetSigBytes updates the signature and invalidates the cached parsed
// signature.
func (c *ChannelEdgePolicy) SetSigBytes(sig []byte) {
c.SigBytes = sig
c.sig = nil
}
// IsDisabled determines whether the edge has the disabled bit set.
func (c *ChannelEdgePolicy) IsDisabled() bool {
return c.ChannelFlags.IsDisabled()
+1 -1
View File
@@ -449,7 +449,7 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
}
// Clear signature to help prevent usage of the previous signature.
edge.SetSigBytes(nil)
edge.SigBytes = nil
return nil
}