multi: rename ChannelAnnouncement to ChannelAnnouncment1

In preparation for adding the new ChannelAnnouncement2 message along
with a ChannelAnnouncement interface, we rename the existing message to
ChannelAnnouncement1.
This commit is contained in:
Elle Mouton committed 2024-09-18 16:13:17 +02:00
1 parent 05d76b696d
commit bb44efa21f
17 files changed
+55 -54

No files matched your search

+13 -13
View File
@@ -849,9 +849,9 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message,
// To avoid inserting edges in the graph for our own channels that we
// have already closed, we ignore such channel announcements coming
// from the remote.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
ownKey := d.selfKey.SerializeCompressed()
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement " +
ownErr := fmt.Errorf("ignoring remote ChannelAnnouncement1 " +
"for own channel")
if bytes.Equal(m.NodeID1[:], ownKey) ||
@@ -1011,7 +1011,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
switch msg := message.msg.(type) {
// Channel announcements are identified by the short channel id field.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
deDupKey := msg.ShortChannelID
sender := route.NewVertex(message.source)
@@ -1585,7 +1585,7 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
case *lnwire.ChannelUpdate:
scid = m.ShortChannelID.ToUint64()
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
scid = m.ShortChannelID.ToUint64()
default:
@@ -1844,7 +1844,7 @@ func remotePubFromChanInfo(chanInfo *models.ChannelEdgeInfo,
// to receive the remote peer's proof, while the remote peer is able to fully
// assemble the proof and craft the ChannelAnnouncement.
func (d *AuthenticatedGossiper) processRejectedEdge(
chanAnnMsg *lnwire.ChannelAnnouncement,
chanAnnMsg *lnwire.ChannelAnnouncement1,
proof *models.ChannelAuthProof) ([]networkMsg, error) {
// First, we'll fetch the state of the channel as we know if from the
@@ -2029,7 +2029,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// *creation* of a new channel within the network. This only advertises
// the existence of a channel and not yet the routing policies in
// either direction of the channel.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
return d.handleChanAnnouncement(nMsg, msg, schedulerOp)
// A new authenticated channel edge update has arrived. This indicates
@@ -2195,7 +2195,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
// updateChannel creates a new fully signed update for the channel, and updates
// the underlying graph with the new state.
func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo,
edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement,
edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
*lnwire.ChannelUpdate, error) {
// Parse the unsigned edge into a channel update.
@@ -2234,10 +2234,10 @@ func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo,
// We'll also create the original channel announcement so the two can
// be broadcast along side each other (if necessary), but only if we
// have a full channel announcement for this channel.
var chanAnn *lnwire.ChannelAnnouncement
var chanAnn *lnwire.ChannelAnnouncement1
if info.AuthProof != nil {
chanID := lnwire.NewShortChanIDFromInt(info.ChannelID)
chanAnn = &lnwire.ChannelAnnouncement{
chanAnn = &lnwire.ChannelAnnouncement1{
ShortChannelID: chanID,
NodeID1: info.NodeKey1Bytes,
NodeID2: info.NodeKey2Bytes,
@@ -2409,18 +2409,18 @@ func (d *AuthenticatedGossiper) handleNodeAnnouncement(nMsg *networkMsg,
// handleChanAnnouncement processes a new channel announcement.
func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
ann *lnwire.ChannelAnnouncement,
ann *lnwire.ChannelAnnouncement1,
ops []batch.SchedulerOption) ([]networkMsg, bool) {
scid := ann.ShortChannelID
log.Debugf("Processing ChannelAnnouncement: peer=%v, short_chan_id=%v",
log.Debugf("Processing ChannelAnnouncement1: peer=%v, short_chan_id=%v",
nMsg.peer, scid.ToUint64())
// We'll ignore any channel announcements that target any chain other
// than the set of chains we know of.
if !bytes.Equal(ann.ChainHash[:], d.cfg.ChainHash[:]) {
err := fmt.Errorf("ignoring ChannelAnnouncement from chain=%v"+
err := fmt.Errorf("ignoring ChannelAnnouncement1 from chain=%v"+
", gossiper on chain=%v", ann.ChainHash,
d.cfg.ChainHash)
log.Errorf(err.Error())
@@ -2788,7 +2788,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
nMsg.err <- nil
log.Debugf("Processed ChannelAnnouncement: peer=%v, short_chan_id=%v",
log.Debugf("Processed ChannelAnnouncement1: peer=%v, short_chan_id=%v",
nMsg.peer, scid.ToUint64())
return announcements, true
+9 -8
View File
@@ -476,7 +476,7 @@ type annBatch struct {
nodeAnn1 *lnwire.NodeAnnouncement
nodeAnn2 *lnwire.NodeAnnouncement
chanAnn *lnwire.ChannelAnnouncement
chanAnn *lnwire.ChannelAnnouncement1
chanUpdAnn1 *lnwire.ChannelUpdate
chanUpdAnn2 *lnwire.ChannelUpdate
@@ -635,9 +635,9 @@ func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate) error {
func createAnnouncementWithoutProof(blockHeight uint32,
key1, key2 *btcec.PublicKey,
extraBytes ...[]byte) *lnwire.ChannelAnnouncement {
extraBytes ...[]byte) *lnwire.ChannelAnnouncement1 {
a := &lnwire.ChannelAnnouncement{
a := &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
TxIndex: 0,
@@ -657,13 +657,13 @@ func createAnnouncementWithoutProof(blockHeight uint32,
}
func createRemoteChannelAnnouncement(blockHeight uint32,
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement, error) {
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement1, error) {
return createChannelAnnouncement(blockHeight, remoteKeyPriv1, remoteKeyPriv2, extraBytes...)
}
func createChannelAnnouncement(blockHeight uint32, key1, key2 *btcec.PrivateKey,
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement, error) {
extraBytes ...[]byte) (*lnwire.ChannelAnnouncement1, error) {
a := createAnnouncementWithoutProof(blockHeight, key1.PubKey(), key2.PubKey(), extraBytes...)
@@ -1768,9 +1768,10 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
// We expect the gossiper to send this message to the remote peer.
select {
case msg := <-sentToPeer:
_, ok := msg.(*lnwire.ChannelAnnouncement)
_, ok := msg.(*lnwire.ChannelAnnouncement1)
if !ok {
t.Fatalf("expected ChannelAnnouncement, instead got %T", msg)
t.Fatalf("expected ChannelAnnouncement1, instead got "+
"%T", msg)
}
case <-time.After(2 * time.Second):
t.Fatal("did not send local proof to peer")
@@ -2811,7 +2812,7 @@ func TestRetransmit(t *testing.T) {
var chanAnn, chanUpd, nodeAnn int
for _, msg := range anns {
switch msg.(type) {
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
chanAnn++
case *lnwire.ChannelUpdate:
chanUpd++
+1 -1
View File
@@ -1447,7 +1447,7 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
// For each channel announcement message, we'll only send this
// message if the channel updates for the channel are between
// our time range.
case *lnwire.ChannelAnnouncement:
case *lnwire.ChannelAnnouncement1:
// First, we'll check if the channel updates are in
// this message batch.
chanUpdates, ok := chanUpdateIndex[msg.ShortChannelID]
+5 -5
View File
@@ -306,7 +306,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
{
// Ann tuple below horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(10),
},
},
@@ -318,7 +318,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
{
// Ann tuple above horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(15),
},
},
@@ -330,7 +330,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
{
// Ann tuple beyond horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
},
},
@@ -343,7 +343,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
{
// Ann w/o an update at all, the update in the DB will
// be below the horizon.
msg: &lnwire.ChannelAnnouncement{
msg: &lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
},
},
@@ -706,7 +706,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
}
queryReply := []lnwire.Message{
&lnwire.ChannelAnnouncement{
&lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
},
&lnwire.ChannelUpdate{