Skip to content

Commit 743502f

Browse files
committed
funding: rename from router graph to graph
1 parent 9327a83 commit 743502f

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

funding/manager.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,11 @@ const (
629629
// but we still haven't announced the channel to the network.
630630
channelReadySent
631631

632-
// addedToRouterGraph is the opening state of a channel if the
633-
// channel has been successfully added to the router graph
634-
// immediately after the channelReady message has been sent, but
635-
// we still haven't announced the channel to the network.
636-
addedToRouterGraph
632+
// addedToGraph is the opening state of a channel if the channel has
633+
// been successfully added to the graph immediately after the
634+
// channelReady message has been sent, but we still haven't announced
635+
// the channel to the network.
636+
addedToGraph
637637
)
638638

639639
func (c channelOpeningState) String() string {
@@ -642,8 +642,8 @@ func (c channelOpeningState) String() string {
642642
return "markedOpen"
643643
case channelReadySent:
644644
return "channelReadySent"
645-
case addedToRouterGraph:
646-
return "addedToRouterGraph"
645+
case addedToGraph:
646+
return "addedToGraph"
647647
default:
648648
return "unknown"
649649
}
@@ -1039,9 +1039,9 @@ func (f *Manager) reservationCoordinator() {
10391039
// advanceFundingState will advance the channel through the steps after the
10401040
// funding transaction is broadcasted, up until the point where the channel is
10411041
// ready for operation. This includes waiting for the funding transaction to
1042-
// confirm, sending channel_ready to the peer, adding the channel to the
1043-
// router graph, and announcing the channel. The updateChan can be set non-nil
1044-
// to get OpenStatusUpdates.
1042+
// confirm, sending channel_ready to the peer, adding the channel to the graph,
1043+
// and announcing the channel. The updateChan can be set non-nil to get
1044+
// OpenStatusUpdates.
10451045
//
10461046
// NOTE: This MUST be run as a goroutine.
10471047
func (f *Manager) advanceFundingState(channel *channeldb.OpenChannel,
@@ -1152,7 +1152,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
11521152
return nil
11531153

11541154
// channelReady was sent to peer, but the channel was not added to the
1155-
// router graph and the channel announcement was not sent.
1155+
// graph and the channel announcement was not sent.
11561156
case channelReadySent:
11571157
// We must wait until we've received the peer's channel_ready
11581158
// before sending a channel_update according to BOLT#07.
@@ -1183,7 +1183,7 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
11831183

11841184
// The channel was added to the Router's topology, but the channel
11851185
// announcement was not sent.
1186-
case addedToRouterGraph:
1186+
case addedToGraph:
11871187
if channel.IsZeroConf() {
11881188
// If this is a zero-conf channel, then we will wait
11891189
// for it to be confirmed before announcing it to the
@@ -3377,15 +3377,15 @@ func (f *Manager) extractAnnounceParams(c *channeldb.OpenChannel) (
33773377
return fwdMinHTLC, fwdMaxHTLC
33783378
}
33793379

3380-
// addToRouterGraph sends a ChannelAnnouncement and a ChannelUpdate to the
3381-
// gossiper so that the channel is added to the Router's internal graph.
3380+
// addToGraph sends a ChannelAnnouncement and a ChannelUpdate to the
3381+
// gossiper so that the channel is added to the graph builder's internal graph.
33823382
// These announcement messages are NOT broadcasted to the greater network,
33833383
// only to the channel counter party. The proofs required to announce the
33843384
// channel to the greater network will be created and sent in annAfterSixConfs.
33853385
// The peerAlias is used for zero-conf channels to give the counter-party a
33863386
// ChannelUpdate they understand. ourPolicy may be set for various
33873387
// option-scid-alias channels to re-use the same policy.
3388-
func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
3388+
func (f *Manager) addToGraph(completeChan *channeldb.OpenChannel,
33893389
shortChanID *lnwire.ShortChannelID,
33903390
peerAlias *lnwire.ShortChannelID,
33913391
ourPolicy *models.ChannelEdgePolicy) error {
@@ -3454,8 +3454,8 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
34543454

34553455
// annAfterSixConfs broadcasts the necessary channel announcement messages to
34563456
// the network after 6 confs. Should be called after the channelReady message
3457-
// is sent and the channel is added to the router graph (channelState is
3458-
// 'addedToRouterGraph') and the channel is ready to be used. This is the last
3457+
// is sent and the channel is added to the graph (channelState is
3458+
// 'addedToGraph') and the channel is ready to be used. This is the last
34593459
// step in the channel opening process, and the opening state will be deleted
34603460
// from the database if successful.
34613461
func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
@@ -3566,7 +3566,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
35663566
}
35673567

35683568
// We'll delete the edge and add it again via
3569-
// addToRouterGraph. This is because the peer may have
3569+
// addToGraph. This is because the peer may have
35703570
// sent us a ChannelUpdate with an alias and we don't
35713571
// want to relay this.
35723572
ourPolicy, err := f.cfg.DeleteAliasEdge(baseScid)
@@ -3576,12 +3576,12 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
35763576
err)
35773577
}
35783578

3579-
err = f.addToRouterGraph(
3579+
err = f.addToGraph(
35803580
completeChan, &baseScid, nil, ourPolicy,
35813581
)
35823582
if err != nil {
35833583
return fmt.Errorf("failed to re-add to "+
3584-
"router graph: %v", err)
3584+
"graph: %v", err)
35853585
}
35863586
}
35873587

@@ -3605,9 +3605,9 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
36053605
return nil
36063606
}
36073607

3608-
// waitForZeroConfChannel is called when the state is addedToRouterGraph with
3608+
// waitForZeroConfChannel is called when the state is addedToGraph with
36093609
// a zero-conf channel. This will wait for the real confirmation, add the
3610-
// confirmed SCID to the router graph, and then announce after six confs.
3610+
// confirmed SCID to the graph, and then announce after six confs.
36113611
func (f *Manager) waitForZeroConfChannel(c *channeldb.OpenChannel) error {
36123612
// First we'll check whether the channel is confirmed on-chain. If it
36133613
// is already confirmed, the chainntnfs subsystem will return with the
@@ -3662,15 +3662,15 @@ func (f *Manager) waitForZeroConfChannel(c *channeldb.OpenChannel) error {
36623662
}
36633663

36643664
// We'll need to update the graph with the new ShortChannelID
3665-
// via an addToRouterGraph call. We don't pass in the peer's
3665+
// via an addToGraph call. We don't pass in the peer's
36663666
// alias since we'll be using the confirmed SCID from now on
36673667
// regardless if it's public or not.
3668-
err = f.addToRouterGraph(
3668+
err = f.addToGraph(
36693669
c, &confChan.shortChanID, nil, ourPolicy,
36703670
)
36713671
if err != nil {
36723672
return fmt.Errorf("failed adding confirmed zero-conf "+
3673-
"SCID to router graph: %v", err)
3673+
"SCID to graph: %v", err)
36743674
}
36753675
}
36763676

@@ -3972,7 +3972,7 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer, //nolint:funlen
39723972
// handleChannelReadyReceived is called once the remote's channelReady message
39733973
// is received and processed. At this stage, we must have sent out our
39743974
// channelReady message, once the remote's channelReady is processed, the
3975-
// channel is now active, thus we change its state to `addedToRouterGraph` to
3975+
// channel is now active, thus we change its state to `addedToGraph` to
39763976
// let the channel start handling routing.
39773977
func (f *Manager) handleChannelReadyReceived(channel *channeldb.OpenChannel,
39783978
scid *lnwire.ShortChannelID, pendingChanID [32]byte,
@@ -4004,25 +4004,25 @@ func (f *Manager) handleChannelReadyReceived(channel *channeldb.OpenChannel,
40044004
peerAlias = &foundAlias
40054005
}
40064006

4007-
err := f.addToRouterGraph(channel, scid, peerAlias, nil)
4007+
err := f.addToGraph(channel, scid, peerAlias, nil)
40084008
if err != nil {
4009-
return fmt.Errorf("failed adding to router graph: %w", err)
4009+
return fmt.Errorf("failed adding to graph: %w", err)
40104010
}
40114011

40124012
// As the channel is now added to the ChannelRouter's topology, the
40134013
// channel is moved to the next state of the state machine. It will be
40144014
// moved to the last state (actually deleted from the database) after
40154015
// the channel is finally announced.
40164016
err = f.saveChannelOpeningState(
4017-
&channel.FundingOutpoint, addedToRouterGraph, scid,
4017+
&channel.FundingOutpoint, addedToGraph, scid,
40184018
)
40194019
if err != nil {
40204020
return fmt.Errorf("error setting channel state to"+
4021-
" addedToRouterGraph: %w", err)
4021+
" addedToGraph: %w", err)
40224022
}
40234023

40244024
log.Debugf("Channel(%v) with ShortChanID %v: successfully "+
4025-
"added to router graph", chanID, scid)
4025+
"added to graph", chanID, scid)
40264026

40274027
// Give the caller a final update notifying them that the channel is
40284028
fundingPoint := channel.FundingOutpoint
@@ -4347,7 +4347,7 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
43474347
}
43484348

43494349
// We only send the channel proof announcement and the node announcement
4350-
// because addToRouterGraph previously sent the ChannelAnnouncement and
4350+
// because addToGraph previously sent the ChannelAnnouncement and
43514351
// the ChannelUpdate announcement messages. The channel proof and node
43524352
// announcements are broadcast to the greater network.
43534353
errChan := f.cfg.SendAnnouncement(ann.chanProof)

funding/manager_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,13 +1140,13 @@ func assertChannelReadySent(t *testing.T, alice, bob *testNode,
11401140
assertDatabaseState(t, bob, fundingOutPoint, channelReadySent)
11411141
}
11421142

1143-
func assertAddedToRouterGraph(t *testing.T, alice, bob *testNode,
1143+
func assertAddedToGraph(t *testing.T, alice, bob *testNode,
11441144
fundingOutPoint *wire.OutPoint) {
11451145

11461146
t.Helper()
11471147

1148-
assertDatabaseState(t, alice, fundingOutPoint, addedToRouterGraph)
1149-
assertDatabaseState(t, bob, fundingOutPoint, addedToRouterGraph)
1148+
assertDatabaseState(t, alice, fundingOutPoint, addedToGraph)
1149+
assertDatabaseState(t, bob, fundingOutPoint, addedToGraph)
11501150
}
11511151

11521152
// assertChannelAnnouncements checks that alice and bob both sends the expected
@@ -1523,7 +1523,7 @@ func testNormalWorkflow(t *testing.T, chanType *lnwire.ChannelType) {
15231523
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
15241524

15251525
// Check that the state machine is updated accordingly
1526-
assertAddedToRouterGraph(t, alice, bob, fundingOutPoint)
1526+
assertAddedToGraph(t, alice, bob, fundingOutPoint)
15271527

15281528
// The funding transaction is now confirmed, wait for the
15291529
// OpenStatusUpdate_ChanOpen update
@@ -1877,7 +1877,7 @@ func TestFundingManagerRestartBehavior(t *testing.T) {
18771877
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
18781878

18791879
// Check that the state machine is updated accordingly
1880-
assertAddedToRouterGraph(t, alice, bob, fundingOutPoint)
1880+
assertAddedToGraph(t, alice, bob, fundingOutPoint)
18811881

18821882
// Next, we check that Alice sends the announcement signatures
18831883
// on restart after six confirmations. Bob should as expected send
@@ -2042,7 +2042,7 @@ func TestFundingManagerOfflinePeer(t *testing.T) {
20422042
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
20432043

20442044
// Check that the state machine is updated accordingly
2045-
assertAddedToRouterGraph(t, alice, bob, fundingOutPoint)
2045+
assertAddedToGraph(t, alice, bob, fundingOutPoint)
20462046

20472047
// The funding transaction is now confirmed, wait for the
20482048
// OpenStatusUpdate_ChanOpen update
@@ -2501,7 +2501,7 @@ func TestFundingManagerReceiveChannelReadyTwice(t *testing.T) {
25012501
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
25022502

25032503
// Check that the state machine is updated accordingly
2504-
assertAddedToRouterGraph(t, alice, bob, fundingOutPoint)
2504+
assertAddedToGraph(t, alice, bob, fundingOutPoint)
25052505

25062506
// The funding transaction is now confirmed, wait for the
25072507
// OpenStatusUpdate_ChanOpen update
@@ -2594,7 +2594,7 @@ func TestFundingManagerRestartAfterChanAnn(t *testing.T) {
25942594
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
25952595

25962596
// Check that the state machine is updated accordingly
2597-
assertAddedToRouterGraph(t, alice, bob, fundingOutPoint)
2597+
assertAddedToGraph(t, alice, bob, fundingOutPoint)
25982598

25992599
// The funding transaction is now confirmed, wait for the
26002600
// OpenStatusUpdate_ChanOpen update
@@ -2698,7 +2698,7 @@ func TestFundingManagerRestartAfterReceivingChannelReady(t *testing.T) {
26982698
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
26992699

27002700
// Check that the state machine is updated accordingly
2701-
assertAddedToRouterGraph(t, alice, bob, fundingOutPoint)
2701+
assertAddedToGraph(t, alice, bob, fundingOutPoint)
27022702

27032703
// Notify that six confirmations has been reached on funding
27042704
// transaction.
@@ -2912,9 +2912,9 @@ func TestFundingManagerPrivateRestart(t *testing.T) {
29122912
// announcements.
29132913
assertChannelAnnouncements(t, alice, bob, capacity, nil, nil, nil, nil)
29142914

2915-
// Note: We don't check for the addedToRouterGraph state because in
2915+
// Note: We don't check for the addedToGraph state because in
29162916
// the private channel mode, the state is quickly changed from
2917-
// addedToRouterGraph to deleted from the database since the public
2917+
// addedToGraph to deleted from the database since the public
29182918
// announcement phase is skipped.
29192919

29202920
// The funding transaction is now confirmed, wait for the
@@ -4563,8 +4563,8 @@ func testZeroConf(t *testing.T, chanType *lnwire.ChannelType) {
45634563
// We'll now wait for the OpenStatusUpdate_ChanOpen update.
45644564
waitForOpenUpdate(t, updateChan)
45654565

4566-
// Assert that both Alice & Bob are in the addedToRouterGraph state.
4567-
assertAddedToRouterGraph(t, alice, bob, fundingOp)
4566+
// Assert that both Alice & Bob are in the addedToGraph state.
4567+
assertAddedToGraph(t, alice, bob, fundingOp)
45684568

45694569
// We'll now restart Alice's funding manager and assert that the tx
45704570
// is rebroadcast.

0 commit comments

Comments
 (0)