channeldb: invalidate channel signature cache on update
This commit is contained in:
parent
5090bb27ad
commit
339ff357d1
@ -2735,7 +2735,8 @@ func (c *ChannelAuthProof) IsEmpty() bool {
|
|||||||
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.
|
// signature for validation purposes. Do not set SigBytes directly, but
|
||||||
|
// use SetSigBytes instead to make sure that the cache is invalidated.
|
||||||
SigBytes []byte
|
SigBytes []byte
|
||||||
|
|
||||||
// sig is a cached fully parsed signature.
|
// sig is a cached fully parsed signature.
|
||||||
@ -2814,6 +2815,13 @@ func (c *ChannelEdgePolicy) Signature() (*btcec.Signature, error) {
|
|||||||
return sig, nil
|
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&lnwire.ChanUpdateDisabled ==
|
return c.ChannelFlags&lnwire.ChanUpdateDisabled ==
|
||||||
|
@ -2552,7 +2552,7 @@ func (d *AuthenticatedGossiper) updateChannel(info *channeldb.ChannelEdgeInfo,
|
|||||||
|
|
||||||
// Next, we'll set the new signature in place, and update the reference
|
// Next, we'll set the new signature in place, and update the reference
|
||||||
// in the backing slice.
|
// in the backing slice.
|
||||||
edge.SigBytes = sig.Serialize()
|
edge.SetSigBytes(sig.Serialize())
|
||||||
chanUpdate.Signature, err = lnwire.NewSigFromSignature(sig)
|
chanUpdate.Signature, err = lnwire.NewSigFromSignature(sig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user