multi: rename ChannelUpdate to ChannelUpdate1

In preparation for adding a new ChannelUpdate2 message and a
ChannelUpdate interface, we rename the existing message to
ChannelUpdate1.
This commit is contained in:
Elle Mouton committed 2024-09-18 16:13:17 +02:00
1 parent bb44efa21f
commit 60f331edb1
43 files changed
+198 -172

No files matched your search

+4 -3
View File
@@ -61,7 +61,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
@@ -326,7 +327,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(),
@@ -335,7 +336,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 {
+19 -11
View File
@@ -322,7 +322,7 @@ type Config struct {
// SignAliasUpdate is used to re-sign a channel update using the
// remote's alias if the option-scid-alias feature bit was negotiated.
SignAliasUpdate func(u *lnwire.ChannelUpdate) (*ecdsa.Signature,
SignAliasUpdate func(u *lnwire.ChannelUpdate1) (*ecdsa.Signature,
error)
// FindBaseByAlias finds the SCID stored in the graph by an alias SCID.
@@ -1035,7 +1035,7 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
// Channel updates are identified by the (short channel id,
// channelflags) tuple.
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
sender := route.NewVertex(message.source)
deDupKey := channelUpdateID{
msg.ShortChannelID,
@@ -1047,7 +1047,15 @@ func (d *deDupedAnnouncements) addMsg(message networkMsg) {
if ok {
// If we already have seen this message, record its
// timestamp.
oldTimestamp = mws.msg.(*lnwire.ChannelUpdate).Timestamp
update, ok := mws.msg.(*lnwire.ChannelUpdate1)
if !ok {
log.Errorf("Expected *lnwire.ChannelUpdate1, "+
"got: %T", mws.msg)
return
}
oldTimestamp = update.Timestamp
}
// If we already had this message with a strictly newer
@@ -1582,7 +1590,7 @@ func (d *AuthenticatedGossiper) isRecentlyRejectedMsg(msg lnwire.Message,
var scid uint64
switch m := msg.(type) {
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
scid = m.ShortChannelID.ToUint64()
case *lnwire.ChannelAnnouncement1:
@@ -2035,7 +2043,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// A new authenticated channel edge update has arrived. This indicates
// that the directional information for an already known channel has
// been updated.
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
return d.handleChanUpdate(nMsg, msg, schedulerOp)
// A new signature announcement has been received. This indicates
@@ -2058,7 +2066,7 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(
// should be inspected.
func (d *AuthenticatedGossiper) processZombieUpdate(
chanInfo *models.ChannelEdgeInfo, scid lnwire.ShortChannelID,
msg *lnwire.ChannelUpdate) error {
msg *lnwire.ChannelUpdate1) error {
// The least-significant bit in the flag on the channel update tells us
// which edge is being updated.
@@ -2151,7 +2159,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
// can safely delete the local proof from the database.
return chanInfo.AuthProof != nil
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
_, p1, p2, err := d.cfg.Graph.GetChannelByID(msg.ShortChannelID)
// If the channel cannot be found, it is most likely a leftover
@@ -2196,7 +2204,7 @@ func (d *AuthenticatedGossiper) isMsgStale(msg lnwire.Message) bool {
// the underlying graph with the new state.
func (d *AuthenticatedGossiper) updateChannel(info *models.ChannelEdgeInfo,
edge *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
*lnwire.ChannelUpdate, error) {
*lnwire.ChannelUpdate1, error) {
// Parse the unsigned edge into a channel update.
chanUpdate := netann.UnsignedChannelUpdateFromEdge(info, edge)
@@ -2284,7 +2292,7 @@ func (d *AuthenticatedGossiper) SyncManager() *SyncManager {
// IsKeepAliveUpdate determines whether this channel update is considered a
// keep-alive update based on the previous channel update processed for the same
// direction.
func IsKeepAliveUpdate(update *lnwire.ChannelUpdate,
func IsKeepAliveUpdate(update *lnwire.ChannelUpdate1,
prev *models.ChannelEdgePolicy) bool {
// Both updates should be from the same direction.
@@ -2753,7 +2761,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
// Reprocess the message, making sure we return an
// error to the original caller in case the gossiper
// shuts down.
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
log.Debugf("Reprocessing ChannelUpdate for "+
"shortChanID=%v", scid.ToUint64())
@@ -2796,7 +2804,7 @@ func (d *AuthenticatedGossiper) handleChanAnnouncement(nMsg *networkMsg,
// handleChanUpdate processes a new channel update.
func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
upd *lnwire.ChannelUpdate,
upd *lnwire.ChannelUpdate1,
ops []batch.SchedulerOption) ([]networkMsg, bool) {
log.Debugf("Processing ChannelUpdate: peer=%v, short_chan_id=%v, ",
+15 -15
View File
@@ -478,8 +478,8 @@ type annBatch struct {
chanAnn *lnwire.ChannelAnnouncement1
chanUpdAnn1 *lnwire.ChannelUpdate
chanUpdAnn2 *lnwire.ChannelUpdate
chanUpdAnn1 *lnwire.ChannelUpdate1
chanUpdAnn2 *lnwire.ChannelUpdate1
localProofAnn *lnwire.AnnounceSignatures1
remoteProofAnn *lnwire.AnnounceSignatures1
@@ -585,12 +585,12 @@ func createNodeAnnouncement(priv *btcec.PrivateKey,
func createUpdateAnnouncement(blockHeight uint32,
flags lnwire.ChanUpdateChanFlags,
nodeKey *btcec.PrivateKey, timestamp uint32,
extraBytes ...[]byte) (*lnwire.ChannelUpdate, error) {
extraBytes ...[]byte) (*lnwire.ChannelUpdate1, error) {
var err error
htlcMinMsat := lnwire.MilliSatoshi(prand.Int63())
a := &lnwire.ChannelUpdate{
a := &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight,
},
@@ -618,7 +618,7 @@ func createUpdateAnnouncement(blockHeight uint32,
return a, nil
}
func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate) error {
func signUpdate(nodeKey *btcec.PrivateKey, a *lnwire.ChannelUpdate1) error {
signer := mock.SingleSigner{Privkey: nodeKey}
sig, err := netann.SignAnnouncement(&signer, testKeyLoc, a)
if err != nil {
@@ -749,7 +749,7 @@ func createTestCtx(t *testing.T, startHeight uint32, isChanPeer bool) (
return false
}
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature,
signAliasUpdate := func(*lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) {
return nil, nil
@@ -1462,7 +1462,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
return false
}
signAliasUpdate := func(*lnwire.ChannelUpdate) (*ecdsa.Signature,
signAliasUpdate := func(*lnwire.ChannelUpdate1) (*ecdsa.Signature,
error) {
return nil, nil
@@ -1868,7 +1868,7 @@ func TestDeDuplicatedAnnouncements(t *testing.T) {
t.Fatal("channel update not replaced in batch")
}
assertChannelUpdate := func(channelUpdate *lnwire.ChannelUpdate) {
assertChannelUpdate := func(channelUpdate *lnwire.ChannelUpdate1) {
channelKey := channelUpdateID{
ua3.ShortChannelID,
ua3.ChannelFlags,
@@ -2814,7 +2814,7 @@ func TestRetransmit(t *testing.T) {
switch msg.(type) {
case *lnwire.ChannelAnnouncement1:
chanAnn++
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
chanUpd++
case *lnwire.NodeAnnouncement:
nodeAnn++
@@ -3247,7 +3247,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
// already been announced. We'll keep track of the old message that is
// now stale to use later on.
staleChannelUpdate := batch.chanUpdAnn1
newChannelUpdate := &lnwire.ChannelUpdate{}
newChannelUpdate := &lnwire.ChannelUpdate1{}
*newChannelUpdate = *staleChannelUpdate
newChannelUpdate.Timestamp++
if err := signUpdate(selfKeyPriv, newChannelUpdate); err != nil {
@@ -3301,7 +3301,7 @@ func TestSendChannelUpdateReliably(t *testing.T) {
}
switch msg := msg.(type) {
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
assertMessage(t, staleChannelUpdate, msg)
case *lnwire.AnnounceSignatures1:
assertMessage(t, batch.localProofAnn, msg)
@@ -3505,7 +3505,7 @@ out:
// being the channel our first private channel.
for i := 0; i < numChannels-1; i++ {
assertBroadcastMsg(t, ctx, func(msg lnwire.Message) error {
upd, ok := msg.(*lnwire.ChannelUpdate)
upd, ok := msg.(*lnwire.ChannelUpdate1)
if !ok {
return fmt.Errorf("channel update not "+
"broadcast, instead %T was", msg)
@@ -3529,7 +3529,7 @@ out:
// remote peer via the reliable sender.
select {
case msg := <-sentMsgs:
upd, ok := msg.(*lnwire.ChannelUpdate)
upd, ok := msg.(*lnwire.ChannelUpdate1)
if !ok {
t.Fatalf("channel update not "+
"broadcast, instead %T was", msg)
@@ -3553,7 +3553,7 @@ out:
for {
select {
case msg := <-ctx.broadcastedMessage:
if upd, ok := msg.msg.(*lnwire.ChannelUpdate); ok {
if upd, ok := msg.msg.(*lnwire.ChannelUpdate1); ok {
if upd.ShortChannelID == firstChanID {
t.Fatalf("chan update msg received: %v",
spew.Sdump(msg))
@@ -3885,7 +3885,7 @@ func TestRateLimitChannelUpdates(t *testing.T) {
// We'll define a helper to assert whether updates should be rate
// limited or not depending on their contents.
assertRateLimit := func(update *lnwire.ChannelUpdate, peer lnpeer.Peer,
assertRateLimit := func(update *lnwire.ChannelUpdate1, peer lnpeer.Peer,
shouldRateLimit bool) {
t.Helper()
+9 -3
View File
@@ -85,7 +85,7 @@ func msgShortChanID(msg lnwire.Message) (lnwire.ShortChannelID, error) {
switch msg := msg.(type) {
case *lnwire.AnnounceSignatures1:
shortChanID = msg.ShortChannelID
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
shortChanID = msg.ShortChannelID
default:
return shortChanID, ErrUnsupportedMessage
@@ -160,7 +160,7 @@ func (s *MessageStore) DeleteMessage(msg lnwire.Message,
// In the event that we're attempting to delete a ChannelUpdate
// from the store, we'll make sure that we're actually deleting
// the correct one as it can be overwritten.
if msg, ok := msg.(*lnwire.ChannelUpdate); ok {
if msg, ok := msg.(*lnwire.ChannelUpdate1); ok {
// Deleting a value from a bucket that doesn't exist
// acts as a NOP, so we'll return if a message doesn't
// exist under this key.
@@ -176,7 +176,13 @@ func (s *MessageStore) DeleteMessage(msg lnwire.Message,
// If the timestamps don't match, then the update stored
// should be the latest one, so we'll avoid deleting it.
if msg.Timestamp != dbMsg.(*lnwire.ChannelUpdate).Timestamp {
m, ok := dbMsg.(*lnwire.ChannelUpdate1)
if !ok {
return fmt.Errorf("expected "+
"*lnwire.ChannelUpdate1, got: %T",
dbMsg)
}
if msg.Timestamp != m.Timestamp {
return nil
}
}
+3 -3
View File
@@ -59,8 +59,8 @@ func randAnnounceSignatures() *lnwire.AnnounceSignatures1 {
}
}
func randChannelUpdate() *lnwire.ChannelUpdate {
return &lnwire.ChannelUpdate{
func randChannelUpdate() *lnwire.ChannelUpdate1 {
return &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(rand.Uint64()),
ExtraOpaqueData: make([]byte, 0),
}
@@ -118,7 +118,7 @@ func TestMessageStoreMessages(t *testing.T) {
switch msg := msg.(type) {
case *lnwire.AnnounceSignatures1:
shortChanID = msg.ShortChannelID.ToUint64()
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
shortChanID = msg.ShortChannelID.ToUint64()
default:
t.Fatalf("found unexpected message type %T", msg)
+5 -3
View File
@@ -1406,9 +1406,11 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
// set of channel announcements and channel updates. This will allow us
// to quickly check if we should forward a chan ann, based on the known
// channel updates for a channel.
chanUpdateIndex := make(map[lnwire.ShortChannelID][]*lnwire.ChannelUpdate)
chanUpdateIndex := make(
map[lnwire.ShortChannelID][]*lnwire.ChannelUpdate1,
)
for _, msg := range msgs {
chanUpdate, ok := msg.msg.(*lnwire.ChannelUpdate)
chanUpdate, ok := msg.msg.(*lnwire.ChannelUpdate1)
if !ok {
continue
}
@@ -1478,7 +1480,7 @@ func (g *GossipSyncer) FilterGossipMsgs(msgs ...msgWithSenders) {
// For each channel update, we'll only send if it the timestamp
// is between our time range.
case *lnwire.ChannelUpdate:
case *lnwire.ChannelUpdate1:
if passesFilter(msg.Timestamp) {
msgsToSend = append(msgsToSend, msg)
}
+9 -9
View File
@@ -52,7 +52,7 @@ type mockChannelGraphTimeSeries struct {
annResp chan []lnwire.Message
updateReq chan lnwire.ShortChannelID
updateResp chan []*lnwire.ChannelUpdate
updateResp chan []*lnwire.ChannelUpdate1
}
func newMockChannelGraphTimeSeries(
@@ -74,7 +74,7 @@ func newMockChannelGraphTimeSeries(
annResp: make(chan []lnwire.Message, 1),
updateReq: make(chan lnwire.ShortChannelID, 1),
updateResp: make(chan []*lnwire.ChannelUpdate, 1),
updateResp: make(chan []*lnwire.ChannelUpdate1, 1),
}
}
@@ -149,7 +149,7 @@ func (m *mockChannelGraphTimeSeries) FetchChanAnns(chain chainhash.Hash,
return <-m.annResp, nil
}
func (m *mockChannelGraphTimeSeries) FetchChanUpdates(chain chainhash.Hash,
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate, error) {
shortChanID lnwire.ShortChannelID) ([]*lnwire.ChannelUpdate1, error) {
m.updateReq <- shortChanID
@@ -311,7 +311,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
},
{
msg: &lnwire.ChannelUpdate{
msg: &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(10),
Timestamp: unixStamp(5),
},
@@ -323,7 +323,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
},
{
msg: &lnwire.ChannelUpdate{
msg: &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(15),
Timestamp: unixStamp(25002),
},
@@ -335,7 +335,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
},
},
{
msg: &lnwire.ChannelUpdate{
msg: &lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
Timestamp: unixStamp(999999),
},
@@ -369,7 +369,7 @@ func TestGossipSyncerFilterGossipMsgsAllInMemory(t *testing.T) {
}
// If so, then we'll send back the missing update.
chanSeries.updateResp <- []*lnwire.ChannelUpdate{
chanSeries.updateResp <- []*lnwire.ChannelUpdate1{
{
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
Timestamp: unixStamp(5),
@@ -551,7 +551,7 @@ func TestGossipSyncerApplyGossipFilter(t *testing.T) {
// For this first response, we'll send back a proper
// set of messages that should be echoed back.
chanSeries.horizonResp <- []lnwire.Message{
&lnwire.ChannelUpdate{
&lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(25),
Timestamp: unixStamp(5),
},
@@ -709,7 +709,7 @@ func TestGossipSyncerReplyShortChanIDs(t *testing.T) {
&lnwire.ChannelAnnouncement1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
},
&lnwire.ChannelUpdate{
&lnwire.ChannelUpdate1{
ShortChannelID: lnwire.NewShortChanIDFromInt(20),
Timestamp: unixStamp(999999),
},