Skip to content

Commit

Permalink
Merge pull request #8044 from ellemouton/g175Messages
Browse files Browse the repository at this point in the history
[1/7] lnwire: add new Gossip 1.75 messages
  • Loading branch information
Roasbeef authored Sep 18, 2024
2 parents 838a32d + 077273e commit 13a7bec
Show file tree
Hide file tree
Showing 61 changed files with 2,618 additions and 557 deletions.
17 changes: 10 additions & 7 deletions channeldb/waitingproof.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,17 @@ type WaitingProofKey [9]byte
// needed to make channel proof exchange persistent, so that after client
// restart we may receive remote/local half proof and process it.
type WaitingProof struct {
*lnwire.AnnounceSignatures
*lnwire.AnnounceSignatures1
isRemote bool
}

// NewWaitingProof constructs a new waiting prof instance.
func NewWaitingProof(isRemote bool, proof *lnwire.AnnounceSignatures) *WaitingProof {
func NewWaitingProof(isRemote bool,
proof *lnwire.AnnounceSignatures1) *WaitingProof {

return &WaitingProof{
AnnounceSignatures: proof,
isRemote: isRemote,
AnnounceSignatures1: proof,
isRemote: isRemote,
}
}

Expand Down Expand Up @@ -238,7 +240,7 @@ func (p *WaitingProof) Encode(w io.Writer) error {
return fmt.Errorf("expect io.Writer to be *bytes.Buffer")
}

if err := p.AnnounceSignatures.Encode(buf, 0); err != nil {
if err := p.AnnounceSignatures1.Encode(buf, 0); err != nil {
return err
}

Expand All @@ -252,11 +254,12 @@ func (p *WaitingProof) Decode(r io.Reader) error {
return err
}

msg := &lnwire.AnnounceSignatures{}
msg := &lnwire.AnnounceSignatures1{}
if err := msg.Decode(r, 0); err != nil {
return err
}

(*p).AnnounceSignatures = msg
p.AnnounceSignatures1 = msg

return nil
}
2 changes: 1 addition & 1 deletion channeldb/waitingproof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestWaitingProofStore(t *testing.T) {
db, err := MakeTestDB(t)
require.NoError(t, err, "failed to make test database")

proof1 := NewWaitingProof(true, &lnwire.AnnounceSignatures{
proof1 := NewWaitingProof(true, &lnwire.AnnounceSignatures1{
NodeSignature: wireSig,
BitcoinSignature: wireSig,
ExtraOpaqueData: make([]byte, 0),
Expand Down
12 changes: 6 additions & 6 deletions discovery/chan_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/graph"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/netann"
"github.com/lightningnetwork/lnd/routing/route"
Expand Down Expand Up @@ -61,7 +60,8 @@ type ChannelGraphTimeSeries interface {
// specified short channel ID. If no channel updates are known for the
// channel, then an empty slice will be returned.
FetchChanUpdates(chain chainhash.Hash,
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error)
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1,
error)
}

// ChanSeries is an implementation of the ChannelGraphTimeSeries
Expand Down Expand Up @@ -136,7 +136,7 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
if edge1 != nil {
// We don't want to send channel updates that don't
// conform to the spec (anymore).
err := graph.ValidateChannelUpdateFields(0, edge1)
err := netann.ValidateChannelUpdateFields(0, edge1)
if err != nil {
log.Errorf("not sending invalid channel "+
"update %v: %v", edge1, err)
Expand All @@ -145,7 +145,7 @@ func (c *ChanSeries) UpdatesInHorizon(chain chainhash.Hash,
}
}
if edge2 != nil {
err := graph.ValidateChannelUpdateFields(0, edge2)
err := netann.ValidateChannelUpdateFields(0, edge2)
if err != nil {
log.Errorf("not sending invalid channel "+
"update %v: %v", edge2, err)
Expand Down Expand Up @@ -326,7 +326,7 @@ func (c *ChanSeries) FetchChanAnns(chain chainhash.Hash,
//
// NOTE: This is part of the ChannelGraphTimeSeries interface.
func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash,
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error) {
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {

chanInfo, e1, e2, err := c.graph.FetchChannelEdgesByID(
shortChanID.ToUint64(),
Expand All @@ -335,7 +335,7 @@ func (c *ChanSeries) FetchChanUpdates(chain chainhash.Hash,
return nil, err
}

chanUpdates := make([]*lnwire.ChannelUpdate, 0, 2)
chanUpdates := make([]*lnwire.ChannelUpdate1, 0, 2)
if e1 != nil {
chanUpdate, err := netann.ChannelUpdateFromEdge(chanInfo, e1)
if err != nil {
Expand Down
Loading

0 comments on commit 13a7bec

Please sign in to comment.