-
Notifications
You must be signed in to change notification settings - Fork 2.3k
chanstate: migrate consumers to Store interface (PR 2 of channel-state decomposition) #10790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ae9de8d
d08b1b0
1f4a756
8f10cf5
2e7a1d8
186ea36
0376270
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "github.com/lightningnetwork/lnd/chainntnfs" | ||
| "github.com/lightningnetwork/lnd/chanacceptor" | ||
| "github.com/lightningnetwork/lnd/channeldb" | ||
| "github.com/lightningnetwork/lnd/chanstate" | ||
| "github.com/lightningnetwork/lnd/discovery" | ||
| "github.com/lightningnetwork/lnd/fn/v2" | ||
| "github.com/lightningnetwork/lnd/graph" | ||
|
|
@@ -384,8 +385,9 @@ type Config struct { | |
| // so that the channel creation process can be completed. | ||
| Notifier chainntnfs.ChainNotifier | ||
|
|
||
| // ChannelDB is the database that keeps track of all channel state. | ||
| ChannelDB *channeldb.ChannelStateDB | ||
| // ChannelDB is the database that keeps track of channel state used by | ||
| // the funding flow. | ||
| ChannelDB chanstate.Store | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nits: this only appears to use open-channel reads plus channel setup methods. Could this field use a narrower private interface embedding |
||
|
|
||
| // SignMessage signs an arbitrary message with a given public key. The | ||
| // actual digest signed is the double sha-256 of the message. In the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ import ( | |
| "github.com/lightningnetwork/lnd/chainntnfs" | ||
| "github.com/lightningnetwork/lnd/channeldb" | ||
| "github.com/lightningnetwork/lnd/channelnotifier" | ||
| "github.com/lightningnetwork/lnd/chanstate" | ||
| "github.com/lightningnetwork/lnd/contractcourt" | ||
| "github.com/lightningnetwork/lnd/discovery" | ||
| "github.com/lightningnetwork/lnd/feature" | ||
|
|
@@ -259,8 +260,8 @@ type Config struct { | |
| // ChannelLinkConfig. | ||
| InterceptSwitch *htlcswitch.InterceptableSwitch | ||
|
|
||
| // ChannelDB is used to fetch opened channels, and closed channels. | ||
| ChannelDB *channeldb.ChannelStateDB | ||
| // ChannelDB is used to fetch channel state needed by the peer. | ||
| ChannelDB chanstate.Store | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nits: this only needs open-channel reads, closed-channel lookup, and initial forwarding policy access. Could this be narrowed to a small private interface rather than full |
||
|
|
||
| // ChannelGraph is a pointer to the channel graph which is used to | ||
| // query information about the set of known active channels. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ import ( | |
| "github.com/lightningnetwork/lnd/chanfitness" | ||
| "github.com/lightningnetwork/lnd/channeldb" | ||
| "github.com/lightningnetwork/lnd/channelnotifier" | ||
| "github.com/lightningnetwork/lnd/chanstate" | ||
| "github.com/lightningnetwork/lnd/clock" | ||
| "github.com/lightningnetwork/lnd/cluster" | ||
| "github.com/lightningnetwork/lnd/contractcourt" | ||
|
|
@@ -325,7 +326,8 @@ type server struct { | |
| graphDB *graphdb.ChannelGraph | ||
| v1Graph *graphdb.VersionedGraph | ||
|
|
||
| chanStateDB *channeldb.ChannelStateDB | ||
| chanStateDB chanstate.Store | ||
| linkNodeDB *channeldb.LinkNodeDB | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nits: since this only needs |
||
|
|
||
| addrSource channeldb.AddrSource | ||
|
|
||
|
|
@@ -728,13 +730,15 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr, | |
| ) | ||
|
|
||
| addrSource := channeldb.NewMultiAddrSource(dbs.ChanStateDB, v1Graph) | ||
| chanStateDB := dbs.ChanStateDB.ChannelStateDB() | ||
|
|
||
| s := &server{ | ||
| cfg: cfg, | ||
| implCfg: implCfg, | ||
| graphDB: dbs.GraphDB, | ||
| v1Graph: v1Graph, | ||
| chanStateDB: dbs.ChanStateDB.ChannelStateDB(), | ||
| chanStateDB: chanStateDB, | ||
| linkNodeDB: chanStateDB.LinkNodeDB(), | ||
| addrSource: addrSource, | ||
| miscDB: dbs.ChanStateDB, | ||
| invoicesDB: dbs.InvoiceDB, | ||
|
|
@@ -748,9 +752,7 @@ func newServer(ctx context.Context, cfg *Config, listenAddrs []net.Addr, | |
| blockbeatDispatcher: chainio.NewBlockbeatDispatcher( | ||
| cc.ChainNotifier, | ||
| ), | ||
| channelNotifier: channelnotifier.New( | ||
| dbs.ChanStateDB.ChannelStateDB(), | ||
| ), | ||
| channelNotifier: channelnotifier.New(chanStateDB), | ||
|
|
||
| identityECDH: nodeKeyECDH, | ||
| identityKeyLoc: nodeKeyDesc.KeyLocator, | ||
|
|
@@ -3610,7 +3612,7 @@ func (s *server) establishPersistentConnections(ctx context.Context) error { | |
| // Iterate through the list of LinkNodes to find addresses we should | ||
| // attempt to connect to based on our set of previous connections. Set | ||
| // the reconnection port to the default peer port. | ||
| linkNodes, err := s.chanStateDB.LinkNodeDB().FetchAllLinkNodes() | ||
| linkNodes, err := s.linkNodeDB.FetchAllLinkNodes() | ||
| if err != nil && !errors.Is(err, channeldb.ErrLinkNodesNotFound) { | ||
| return fmt.Errorf("failed to fetch all link nodes: %w", err) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits: the notifier only calls
FetchChannelandFetchClosedChannel, so a narrower private interface would preserve the benefit of the sub-interface split without requiring the fullchanstate.Store.