From 1b7c56b2ed1fea1a136762ee68bc6f4c82657ddc Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 16 Mar 2023 04:42:21 +0800 Subject: [PATCH] multi: rename `FundingLocked` to `ChannelReady` This commit is created by running, ```shell gofmt -d -w -r 'FundingLocked -> ChannelReady' . gco master channeldb/migration ``` --- funding/manager.go | 4 ++-- funding/manager_test.go | 46 ++++++++++++++++++++-------------------- htlcswitch/link_test.go | 24 ++++++++++----------- htlcswitch/mock.go | 2 +- htlcswitch/test_utils.go | 2 +- lnwire/funding_locked.go | 14 ++++++------ lnwire/lnwire_test.go | 2 +- lnwire/message.go | 2 +- lnwire/message_test.go | 2 +- peer/brontide.go | 4 ++-- 10 files changed, 51 insertions(+), 51 deletions(-) diff --git a/funding/manager.go b/funding/manager.go index 2d702ba48..113a30343 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -889,7 +889,7 @@ func (f *Manager) reservationCoordinator() { case *lnwire.FundingSigned: f.handleFundingSigned(fmsg.peer, msg) - case *lnwire.FundingLocked: + case *lnwire.ChannelReady: f.wg.Add(1) go f.handleFundingLocked(fmsg.peer, msg) @@ -3394,7 +3394,7 @@ func (f *Manager) waitForZeroConfChannel(c *channeldb.OpenChannel, // handleFundingLocked finalizes the channel funding process and enables the // channel to enter normal operating mode. func (f *Manager) handleFundingLocked(peer lnpeer.Peer, - msg *lnwire.FundingLocked) { + msg *lnwire.ChannelReady) { defer f.wg.Done() log.Debugf("Received FundingLocked for ChannelID(%v) from "+ diff --git a/funding/manager_test.go b/funding/manager_test.go index f386e3de5..0d33e60bb 100644 --- a/funding/manager_test.go +++ b/funding/manager_test.go @@ -901,7 +901,7 @@ func assertFundingMsgSent(t *testing.T, msgChan chan lnwire.Message, case "FundingSigned": sentMsg, ok = msg.(*lnwire.FundingSigned) case "FundingLocked": - sentMsg, ok = msg.(*lnwire.FundingLocked) + sentMsg, ok = msg.(*lnwire.ChannelReady) case "Error": sentMsg, ok = msg.(*lnwire.Error) default: @@ -1408,12 +1408,12 @@ func TestFundingManagerNormalWorkflow(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Check that the state machine is updated accordingly assertFundingLockedSent(t, alice, bob, fundingOutPoint) @@ -1679,7 +1679,7 @@ func TestFundingManagerRestartBehavior(t *testing.T) { // Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Alice should still be markedOpen assertDatabaseState(t, alice, fundingOutPoint, markedOpen) @@ -1708,7 +1708,7 @@ func TestFundingManagerRestartBehavior(t *testing.T) { fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // The state should now be fundingLockedSent assertDatabaseState(t, alice, fundingOutPoint, fundingLockedSent) @@ -1836,7 +1836,7 @@ func TestFundingManagerOfflinePeer(t *testing.T) { // Bob will send funding locked to Alice fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Alice should still be markedOpen assertDatabaseState(t, alice, fundingOutPoint, markedOpen) @@ -1884,7 +1884,7 @@ func TestFundingManagerOfflinePeer(t *testing.T) { // This should make Alice send the fundingLocked. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // The state should now be fundingLockedSent assertDatabaseState(t, alice, fundingOutPoint, fundingLockedSent) @@ -2313,12 +2313,12 @@ func TestFundingManagerReceiveFundingLockedTwice(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Check that the state machine is updated accordingly assertFundingLockedSent(t, alice, bob, fundingOutPoint) @@ -2424,12 +2424,12 @@ func TestFundingManagerRestartAfterChanAnn(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Check that the state machine is updated accordingly assertFundingLockedSent(t, alice, bob, fundingOutPoint) @@ -2521,12 +2521,12 @@ func TestFundingManagerRestartAfterReceivingFundingLocked(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Check that the state machine is updated accordingly assertFundingLockedSent(t, alice, bob, fundingOutPoint) @@ -2614,12 +2614,12 @@ func TestFundingManagerPrivateChannel(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Check that the state machine is updated accordingly assertFundingLockedSent(t, alice, bob, fundingOutPoint) @@ -2737,12 +2737,12 @@ func TestFundingManagerPrivateRestart(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Check that the state machine is updated accordingly assertFundingLockedSent(t, alice, bob, fundingOutPoint) @@ -3172,12 +3172,12 @@ func TestFundingManagerCustomChannelParameters(t *testing.T) { // fundingLocked to Bob. fundingLockedAlice := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // And similarly Bob will send funding locked to Alice. fundingLockedBob := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) // Exchange the fundingLocked messages. alice.fundingMgr.ProcessFundingMsg(fundingLockedBob, bob) @@ -3489,11 +3489,11 @@ func TestFundingManagerMaxPendingChannels(t *testing.T) { // Expect both to be sending FundingLocked. _ = assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) _ = assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) } @@ -4205,14 +4205,14 @@ func TestFundingManagerZeroConf(t *testing.T) { // Assert that Bob's funding_locked message has an AliasScid. bobFundingLocked := assertFundingMsgSent( t, bob.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) require.NotNil(t, bobFundingLocked.AliasScid) require.Equal(t, *bobFundingLocked.AliasScid, alias) // Do the same for Alice as well. aliceFundingLocked := assertFundingMsgSent( t, alice.msgChan, "FundingLocked", - ).(*lnwire.FundingLocked) + ).(*lnwire.ChannelReady) require.NotNil(t, aliceFundingLocked.AliasScid) require.Equal(t, *aliceFundingLocked.AliasScid, alias) diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index b58c8a63b..72afa2ebb 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -1684,8 +1684,8 @@ func TestChannelLinkSingleHopMessageOrdering(t *testing.T) { {"alice", "bob", &lnwire.ChannelReestablish{}, false}, {"bob", "alice", &lnwire.ChannelReestablish{}, false}, - {"alice", "bob", &lnwire.FundingLocked{}, false}, - {"bob", "alice", &lnwire.FundingLocked{}, false}, + {"alice", "bob", &lnwire.ChannelReady{}, false}, + {"bob", "alice", &lnwire.ChannelReady{}, false}, {"alice", "bob", &lnwire.UpdateAddHTLC{}, false}, {"alice", "bob", &lnwire.CommitSig{}, false}, @@ -3303,8 +3303,8 @@ func TestChannelRetransmission(t *testing.T) { {"alice", "bob", &lnwire.ChannelReestablish{}, false}, {"bob", "alice", &lnwire.ChannelReestablish{}, false}, - {"alice", "bob", &lnwire.FundingLocked{}, false}, - {"bob", "alice", &lnwire.FundingLocked{}, false}, + {"alice", "bob", &lnwire.ChannelReady{}, false}, + {"bob", "alice", &lnwire.ChannelReady{}, false}, // Send payment from Alice to Bob and intercept // the last revocation message, in this case @@ -3343,8 +3343,8 @@ func TestChannelRetransmission(t *testing.T) { {"alice", "bob", &lnwire.ChannelReestablish{}, false}, {"bob", "alice", &lnwire.ChannelReestablish{}, false}, - {"alice", "bob", &lnwire.FundingLocked{}, false}, - {"bob", "alice", &lnwire.FundingLocked{}, false}, + {"alice", "bob", &lnwire.ChannelReady{}, false}, + {"bob", "alice", &lnwire.ChannelReady{}, false}, // Send payment from Alice to Bob and intercept // the last revocation message, in this case @@ -3385,8 +3385,8 @@ func TestChannelRetransmission(t *testing.T) { {"alice", "bob", &lnwire.ChannelReestablish{}, false}, {"bob", "alice", &lnwire.ChannelReestablish{}, false}, - {"alice", "bob", &lnwire.FundingLocked{}, false}, - {"bob", "alice", &lnwire.FundingLocked{}, false}, + {"alice", "bob", &lnwire.ChannelReady{}, false}, + {"bob", "alice", &lnwire.ChannelReady{}, false}, // Attempt make a payment from Alice to Bob, // which is intercepted, emulating the Bob @@ -3399,8 +3399,8 @@ func TestChannelRetransmission(t *testing.T) { {"alice", "bob", &lnwire.ChannelReestablish{}, false}, {"bob", "alice", &lnwire.ChannelReestablish{}, false}, - {"alice", "bob", &lnwire.FundingLocked{}, false}, - {"bob", "alice", &lnwire.FundingLocked{}, false}, + {"alice", "bob", &lnwire.ChannelReady{}, false}, + {"bob", "alice", &lnwire.ChannelReady{}, false}, // After Bob has notified Alice that he didn't // receive updates Alice should re-send them. @@ -3816,8 +3816,8 @@ func TestChannelLinkUpdateCommitFee(t *testing.T) { {"alice", "bob", &lnwire.ChannelReestablish{}, false}, {"bob", "alice", &lnwire.ChannelReestablish{}, false}, - {"alice", "bob", &lnwire.FundingLocked{}, false}, - {"bob", "alice", &lnwire.FundingLocked{}, false}, + {"alice", "bob", &lnwire.ChannelReady{}, false}, + {"bob", "alice", &lnwire.ChannelReady{}, false}, // First fee update. {"alice", "bob", &lnwire.UpdateFee{}, false}, diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 866e7d36f..cec170a35 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -627,7 +627,7 @@ func (s *mockServer) readHandler(message lnwire.Message) error { targetChan = msg.ChanID case *lnwire.CommitSig: targetChan = msg.ChanID - case *lnwire.FundingLocked: + case *lnwire.ChannelReady: // Ignore return nil case *lnwire.ChannelReestablish: diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index e1bd6783a..c1bfb1f55 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -495,7 +495,7 @@ func getChanID(msg lnwire.Message) (lnwire.ChannelID, error) { chanID = msg.ChanID case *lnwire.ChannelReestablish: chanID = msg.ChanID - case *lnwire.FundingLocked: + case *lnwire.ChannelReady: chanID = msg.ChanID case *lnwire.UpdateFee: chanID = msg.ChanID diff --git a/lnwire/funding_locked.go b/lnwire/funding_locked.go index fb47356ba..ab741433d 100644 --- a/lnwire/funding_locked.go +++ b/lnwire/funding_locked.go @@ -13,7 +13,7 @@ import ( // blockchain. FundingLocked contains the signatures necessary for the channel // participants to advertise the existence of the channel to the rest of the // network. -type FundingLocked struct { +type ChannelReady struct { // ChanID is the outpoint of the channel's funding transaction. This // can be used to query for the channel in the database. ChanID ChannelID @@ -35,8 +35,8 @@ type FundingLocked struct { // NewFundingLocked creates a new FundingLocked message, populating it with the // necessary IDs and revocation secret. -func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *FundingLocked { - return &FundingLocked{ +func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *ChannelReady { + return &ChannelReady{ ChanID: cid, NextPerCommitmentPoint: npcp, ExtraData: make([]byte, 0), @@ -45,14 +45,14 @@ func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *FundingLocked { // A compile time check to ensure FundingLocked implements the lnwire.Message // interface. -var _ Message = (*FundingLocked)(nil) +var _ Message = (*ChannelReady)(nil) // Decode deserializes the serialized FundingLocked message stored in the // passed io.Reader into the target FundingLocked using the deserialization // rules defined by the passed protocol version. // // This is part of the lnwire.Message interface. -func (c *FundingLocked) Decode(r io.Reader, pver uint32) error { +func (c *ChannelReady) Decode(r io.Reader, pver uint32) error { // Read all the mandatory fields in the message. err := ReadElements(r, &c.ChanID, @@ -85,7 +85,7 @@ func (c *FundingLocked) Decode(r io.Reader, pver uint32) error { // protocol version. // // This is part of the lnwire.Message interface. -func (c *FundingLocked) Encode(w *bytes.Buffer, pver uint32) error { +func (c *ChannelReady) Encode(w *bytes.Buffer, pver uint32) error { if err := WriteChannelID(w, c.ChanID); err != nil { return err } @@ -110,6 +110,6 @@ func (c *FundingLocked) Encode(w *bytes.Buffer, pver uint32) error { // FundingLocked message on the wire. // // This is part of the lnwire.Message interface. -func (c *FundingLocked) MsgType() MessageType { +func (c *ChannelReady) MsgType() MessageType { return MsgFundingLocked } diff --git a/lnwire/lnwire_test.go b/lnwire/lnwire_test.go index 96d0c8ae5..d4b4e7dab 100644 --- a/lnwire/lnwire_test.go +++ b/lnwire/lnwire_test.go @@ -1014,7 +1014,7 @@ func TestLightningWireProtocol(t *testing.T) { }, { msgType: MsgFundingLocked, - scenario: func(m FundingLocked) bool { + scenario: func(m ChannelReady) bool { return mainScenario(&m) }, }, diff --git a/lnwire/message.go b/lnwire/message.go index 2e71173e5..7ededf595 100644 --- a/lnwire/message.go +++ b/lnwire/message.go @@ -191,7 +191,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) { case MsgFundingSigned: msg = &FundingSigned{} case MsgFundingLocked: - msg = &FundingLocked{} + msg = &ChannelReady{} case MsgShutdown: msg = &Shutdown{} case MsgClosingSigned: diff --git a/lnwire/message_test.go b/lnwire/message_test.go index 090978a74..b016fc35c 100644 --- a/lnwire/message_test.go +++ b/lnwire/message_test.go @@ -442,7 +442,7 @@ func newMsgFundingSigned(t testing.TB, r io.Reader) *lnwire.FundingSigned { return msg } -func newMsgFundingLocked(t testing.TB, r io.Reader) *lnwire.FundingLocked { +func newMsgFundingLocked(t testing.TB, r io.Reader) *lnwire.ChannelReady { t.Helper() var c [32]byte diff --git a/peer/brontide.go b/peer/brontide.go index 9ea85edd1..fda3f01e1 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -1545,7 +1545,7 @@ out: *lnwire.AcceptChannel, *lnwire.FundingCreated, *lnwire.FundingSigned, - *lnwire.FundingLocked: + *lnwire.ChannelReady: p.cfg.FundingManager.ProcessFundingMsg(msg, p) @@ -1794,7 +1794,7 @@ func messageSummary(msg lnwire.Message) string { case *lnwire.FundingSigned: return fmt.Sprintf("chan_id=%v", msg.ChanID) - case *lnwire.FundingLocked: + case *lnwire.ChannelReady: return fmt.Sprintf("chan_id=%v, next_point=%x", msg.ChanID, msg.NextPerCommitmentPoint.SerializeCompressed())