multi: rename FundingLocked to ChannelReady

This commit is created by running,

```shell
gofmt -d -w -r 'FundingLocked -> ChannelReady' .

gco master channeldb/migration
```
This commit is contained in:
yyforyongyu committed 2023-03-17 18:21:58 +08:00
1 parent ae39cd9e91
commit 1b7c56b2ed
10 files changed
+51 -51

No files matched your search

+2 -2
View File
@@ -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 "+
+23 -23
View File
@@ -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)
+12 -12
View File
@@ -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},
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -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
+7 -7
View File
@@ -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
}
+1 -1
View File
@@ -1014,7 +1014,7 @@ func TestLightningWireProtocol(t *testing.T) {
},
{
msgType: MsgFundingLocked,
scenario: func(m FundingLocked) bool {
scenario: func(m ChannelReady) bool {
return mainScenario(&m)
},
},
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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())