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:
2 files changed
+2
-34
No files matched your search
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
|
||||||
"github.com/lightningnetwork/lnd/fn/v2"
|
"github.com/lightningnetwork/lnd/fn/v2"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
)
|
)
|
||||||
@@ -17,13 +16,9 @@ import (
|
|||||||
type ChannelEdgePolicy struct {
|
type ChannelEdgePolicy struct {
|
||||||
// SigBytes is the raw bytes of the signature of the channel edge
|
// 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
|
// policy. We'll only parse these if the caller needs to access the
|
||||||
// signature for validation purposes. Do not set SigBytes directly, but
|
// signature for validation purposes.
|
||||||
// use SetSigBytes instead to make sure that the cache is invalidated.
|
|
||||||
SigBytes []byte
|
SigBytes []byte
|
||||||
|
|
||||||
// sig is a cached fully parsed signature.
|
|
||||||
sig *ecdsa.Signature
|
|
||||||
|
|
||||||
// ChannelID is the unique channel ID for the channel. The first 3
|
// 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,
|
// 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.
|
// and the last 2 bytes are the output index for the channel.
|
||||||
@@ -84,33 +79,6 @@ type ChannelEdgePolicy struct {
|
|||||||
ExtraOpaqueData lnwire.ExtraOpaqueData
|
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.
|
// IsDisabled determines whether the edge has the disabled bit set.
|
||||||
func (c *ChannelEdgePolicy) IsDisabled() bool {
|
func (c *ChannelEdgePolicy) IsDisabled() bool {
|
||||||
return c.ChannelFlags.IsDisabled()
|
return c.ChannelFlags.IsDisabled()
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ func (r *Manager) updateEdge(chanPoint wire.OutPoint,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear signature to help prevent usage of the previous signature.
|
// Clear signature to help prevent usage of the previous signature.
|
||||||
edge.SetSigBytes(nil)
|
edge.SigBytes = nil
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user