multi: rename AnnounceSignatures to AnnounceSignatures1

In preparation for adding a new message, AnnounceSignatures2 along with
an AnnounceSignatures interface, we rename the existing message to
AnnounceSignatures1.
This commit is contained in:
Elle Mouton 2024-08-21 08:34:57 +02:00
parent edd9ade7e5
commit 05d76b696d
No known key found for this signature in database
GPG Key ID: D7D916376026F177
14 changed files with 47 additions and 44 deletions

View File

@ -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,
}
}
@ -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
}
@ -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
}

View File

@ -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),

View File

@ -1416,7 +1416,7 @@ func (d *AuthenticatedGossiper) networkHandler() {
switch announcement.msg.(type) {
// Channel announcement signatures are amongst the only
// messages that we'll process serially.
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
emittedAnnouncements, _ := d.processNetworkAnnouncement(
announcement,
)
@ -2041,7 +2041,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// A new signature announcement has been received. This indicates
// willingness of nodes involved in the funding of a channel to
// announce this new channel to the rest of the world.
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
return d.handleAnnSig(nMsg, msg)
default:
@ -2129,7 +2129,7 @@ func (d *AuthenticatedGossiper) fetchNodeAnn(
// MessageStore is seen as stale by the current graph.
func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
switch msg := msg.(type) {
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
chanInfo, _, _, err := d.cfg.Graph.GetChannelByID(
msg.ShortChannelID,
)
@ -3200,7 +3200,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
// handleAnnSig processes a new announcement signatures message.
func (d *AuthenticatedGossiper) handleAnnSig(nMsg *networkMsg,
ann *lnwire.AnnounceSignatures) ([]networkMsg, bool) {
ann *lnwire.AnnounceSignatures1) ([]networkMsg, bool) {
needBlockHeight := ann.ShortChannelID.BlockHeight +
d.cfg.ProofMatureDelta

View File

@ -481,8 +481,8 @@ type annBatch struct {
chanUpdAnn1 *lnwire.ChannelUpdate
chanUpdAnn2 *lnwire.ChannelUpdate
localProofAnn *lnwire.AnnounceSignatures
remoteProofAnn *lnwire.AnnounceSignatures
localProofAnn *lnwire.AnnounceSignatures1
remoteProofAnn *lnwire.AnnounceSignatures1
}
func createLocalAnnouncements(blockHeight uint32) (*annBatch, error) {
@ -513,7 +513,7 @@ func createAnnouncements(blockHeight uint32, key1, key2 *btcec.PrivateKey) (*ann
return nil, err
}
batch.remoteProofAnn = &lnwire.AnnounceSignatures{
batch.remoteProofAnn = &lnwire.AnnounceSignatures1{
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
},
@ -521,7 +521,7 @@ func createAnnouncements(blockHeight uint32, key1, key2 *btcec.PrivateKey) (*ann
BitcoinSignature: batch.chanAnn.BitcoinSig2,
}
batch.localProofAnn = &lnwire.AnnounceSignatures{
batch.localProofAnn = &lnwire.AnnounceSignatures1{
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
},
@ -1540,7 +1540,7 @@ out:
case msg := <-sentToPeer:
// Since the ChannelUpdate will also be resent as it is
// sent reliably, we'll need to filter it out.
if _, ok := msg.(*lnwire.AnnounceSignatures); !ok {
if _, ok := msg.(*lnwire.AnnounceSignatures1); !ok {
continue
}
@ -3302,7 +3302,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
switch msg := msg.(type) {
case *lnwire.ChannelUpdate:
assertMessage(t, staleChannelUpdate, msg)
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
assertMessage(t, batch.localProofAnn, msg)
default:
t.Fatalf("send unexpected %v message", msg.MsgType())

View File

@ -83,7 +83,7 @@ func NewMessageStore(db kvdb.Backend) (*MessageStore, error) {
func msgShortChanID(msg lnwire.Message) (lnwire.ShortChannelID, error) {
var shortChanID lnwire.ShortChannelID
switch msg := msg.(type) {
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
shortChanID = msg.ShortChannelID
case *lnwire.ChannelUpdate:
shortChanID = msg.ShortChannelID

View File

@ -52,8 +52,8 @@ func randCompressedPubKey(t *testing.T) [33]byte {
return compressedPubKey
}
func randAnnounceSignatures() *lnwire.AnnounceSignatures {
return &lnwire.AnnounceSignatures{
func randAnnounceSignatures() *lnwire.AnnounceSignatures1 {
return &lnwire.AnnounceSignatures1{
ShortChannelID: lnwire.NewShortChanIDFromInt(rand.Uint64()),
ExtraOpaqueData: make([]byte, 0),
}
@ -116,7 +116,7 @@ func TestMessageStoreMessages(t *testing.T) {
for _, msg := range peerMsgs {
var shortChanID uint64
switch msg := msg.(type) {
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
shortChanID = msg.ShortChannelID.ToUint64()
case *lnwire.ChannelUpdate:
shortChanID = msg.ShortChannelID.ToUint64()

View File

@ -4145,7 +4145,7 @@ func (f *Manager) ensureInitialForwardingPolicy(chanID lnwire.ChannelID,
type chanAnnouncement struct {
chanAnn *lnwire.ChannelAnnouncement
chanUpdateAnn *lnwire.ChannelUpdate
chanProof *lnwire.AnnounceSignatures
chanProof *lnwire.AnnounceSignatures1
}
// newChanAnnouncement creates the authenticated channel announcement messages
@ -4337,7 +4337,7 @@ func (f *Manager) newChanAnnouncement(localPubKey,
// Finally, we'll generate the announcement proof which we'll use to
// provide the other side with the necessary signatures required to
// allow them to reconstruct the full channel announcement.
proof := &lnwire.AnnounceSignatures{
proof := &lnwire.AnnounceSignatures1{
ChannelID: chanID,
ShortChannelID: shortChanID,
}

View File

@ -1297,7 +1297,7 @@ func assertAnnouncementSignatures(t *testing.T, alice, bob *testNode) {
gotNodeAnnouncement := false
for _, msg := range announcements {
switch msg.(type) {
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
gotAnnounceSignatures = true
case *lnwire.NodeAnnouncement:
gotNodeAnnouncement = true

View File

@ -153,7 +153,7 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) {
return
case *channeldb.LightningNode:
return
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
// TODO(roasbeef): need to wait on chan ann?
return
}
@ -216,7 +216,7 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error {
// Other types of jobs can be executed immediately, so we'll just
// return directly.
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
// TODO(roasbeef): need to wait on chan ann?
case *models.ChannelEdgeInfo:
case *lnwire.ChannelAnnouncement:
@ -301,7 +301,7 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) {
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
delete(v.chanEdgeDependencies, shortID)
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
return
}
}

View File

@ -5,11 +5,11 @@ import (
"io"
)
// AnnounceSignatures is a direct message between two endpoints of a
// AnnounceSignatures1 is a direct message between two endpoints of a
// channel and serves as an opt-in mechanism to allow the announcement of
// the channel to the rest of the network. It contains the necessary
// signatures by the sender to construct the channel announcement message.
type AnnounceSignatures struct {
type AnnounceSignatures1 struct {
// ChannelID is the unique description of the funding transaction.
// Channel id is better for users and debugging and short channel id is
// used for quick test on existence of the particular utxo inside the
@ -43,15 +43,15 @@ type AnnounceSignatures struct {
ExtraOpaqueData ExtraOpaqueData
}
// A compile time check to ensure AnnounceSignatures implements the
// A compile time check to ensure AnnounceSignatures1 implements the
// lnwire.Message interface.
var _ Message = (*AnnounceSignatures)(nil)
var _ Message = (*AnnounceSignatures1)(nil)
// Decode deserializes a serialized AnnounceSignatures stored in the passed
// Decode deserializes a serialized AnnounceSignatures1 stored in the passed
// io.Reader observing the specified protocol version.
//
// This is part of the lnwire.Message interface.
func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
func (a *AnnounceSignatures1) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&a.ChannelID,
&a.ShortChannelID,
@ -61,11 +61,11 @@ func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
)
}
// Encode serializes the target AnnounceSignatures into the passed io.Writer
// Encode serializes the target AnnounceSignatures1 into the passed io.Writer
// observing the protocol version specified.
//
// This is part of the lnwire.Message interface.
func (a *AnnounceSignatures) Encode(w *bytes.Buffer, pver uint32) error {
func (a *AnnounceSignatures1) Encode(w *bytes.Buffer, pver uint32) error {
if err := WriteChannelID(w, a.ChannelID); err != nil {
return err
}
@ -89,6 +89,6 @@ func (a *AnnounceSignatures) Encode(w *bytes.Buffer, pver uint32) error {
// wire.
//
// This is part of the lnwire.Message interface.
func (a *AnnounceSignatures) MsgType() MessageType {
func (a *AnnounceSignatures1) MsgType() MessageType {
return MsgAnnounceSignatures
}

View File

@ -1138,7 +1138,7 @@ func TestLightningWireProtocol(t *testing.T) {
},
MsgAnnounceSignatures: func(v []reflect.Value, r *rand.Rand) {
var err error
req := AnnounceSignatures{
req := AnnounceSignatures1{
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
ExtraOpaqueData: make([]byte, 0),
}
@ -1649,7 +1649,7 @@ func TestLightningWireProtocol(t *testing.T) {
},
{
msgType: MsgAnnounceSignatures,
scenario: func(m AnnounceSignatures) bool {
scenario: func(m AnnounceSignatures1) bool {
return mainScenario(&m)
},
},

View File

@ -267,7 +267,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
case MsgPing:
msg = &Ping{}
case MsgAnnounceSignatures:
msg = &AnnounceSignatures{}
msg = &AnnounceSignatures1{}
case MsgPong:
msg = &Pong{}
case MsgQueryShortChanIDs:

View File

@ -727,11 +727,11 @@ func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate {
}
func newMsgAnnounceSignatures(t testing.TB,
r *rand.Rand) *lnwire.AnnounceSignatures {
r *rand.Rand) *lnwire.AnnounceSignatures1 {
t.Helper()
msg := &lnwire.AnnounceSignatures{
msg := &lnwire.AnnounceSignatures1{
ShortChannelID: lnwire.NewShortChanIDFromInt(
uint64(r.Int63()),
),

View File

@ -1966,7 +1966,7 @@ out:
case *lnwire.ChannelUpdate,
*lnwire.ChannelAnnouncement,
*lnwire.NodeAnnouncement,
*lnwire.AnnounceSignatures,
*lnwire.AnnounceSignatures1,
*lnwire.GossipTimestampRange,
*lnwire.QueryShortChanIDs,
*lnwire.QueryChannelRange,
@ -2225,7 +2225,7 @@ func messageSummary(msg lnwire.Message) string {
case *lnwire.Error:
return fmt.Sprintf("%v", msg.Error())
case *lnwire.AnnounceSignatures:
case *lnwire.AnnounceSignatures1:
return fmt.Sprintf("chan_id=%v, short_chan_id=%v", msg.ChannelID,
msg.ShortChannelID.ToUint64())