From 6fda2e8da9ca1de6be8c6323f98d54691ab93e5d Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Wed, 19 Nov 2025 07:50:55 +0200 Subject: [PATCH] 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. --- graph/db/models/channel_edge_policy.go | 34 +------------------------- routing/localchans/manager.go | 2 +- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/graph/db/models/channel_edge_policy.go b/graph/db/models/channel_edge_policy.go index 48d748ee0..a2661ef6f 100644 --- a/graph/db/models/channel_edge_policy.go +++ b/graph/db/models/channel_edge_policy.go @@ -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() diff --git a/routing/localchans/manager.go b/routing/localchans/manager.go index a48486e7b..1a7c1d585 100644 --- a/routing/localchans/manager.go +++ b/routing/localchans/manager.go @@ -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 }