refactor: move various duties from ChannelRouter to graph.Builder
This commit is a large refactor that moves over various responsibilities from the ChannelRouter to the graph.Builder. These include all graph related tasks such as: - graph pruning - validation of new network updates & persisting new updates - notifying topology update clients of any changes. This is a large commit but: - many of the files are purely moved from `routing` to `graph` - the business logic put in the graph Builder is copied exactly as is from the ChannelRouter with one exception: - The ChannelRouter just needs to be able to call the Builder's `ApplyChannelUpdate` method. So this is now exported and provided to the ChannelRouter as a config option. - The trickiest part was just moving over the test code since quite a bit had to be duplicated.
This commit is contained in:
26 files changed
+5121
-3862
No files matched your search
+13
-13
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
"github.com/lightningnetwork/lnd/discovery"
|
||||
"github.com/lightningnetwork/lnd/graph"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/labels"
|
||||
@@ -33,7 +34,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
"golang.org/x/crypto/salsa20"
|
||||
)
|
||||
|
||||
@@ -3415,10 +3415,10 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
|
||||
select {
|
||||
case err := <-errChan:
|
||||
if err != nil {
|
||||
if routing.IsError(err, routing.ErrOutdated,
|
||||
routing.ErrIgnored) {
|
||||
if graph.IsError(err, graph.ErrOutdated,
|
||||
graph.ErrIgnored) {
|
||||
|
||||
log.Debugf("Router rejected "+
|
||||
log.Debugf("Graph rejected "+
|
||||
"ChannelAnnouncement: %v", err)
|
||||
} else {
|
||||
return fmt.Errorf("error sending channel "+
|
||||
@@ -3435,10 +3435,10 @@ func (f *Manager) addToRouterGraph(completeChan *channeldb.OpenChannel,
|
||||
select {
|
||||
case err := <-errChan:
|
||||
if err != nil {
|
||||
if routing.IsError(err, routing.ErrOutdated,
|
||||
routing.ErrIgnored) {
|
||||
if graph.IsError(err, graph.ErrOutdated,
|
||||
graph.ErrIgnored) {
|
||||
|
||||
log.Debugf("Router rejected "+
|
||||
log.Debugf("Graph rejected "+
|
||||
"ChannelUpdate: %v", err)
|
||||
} else {
|
||||
return fmt.Errorf("error sending channel "+
|
||||
@@ -4354,10 +4354,10 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
|
||||
select {
|
||||
case err := <-errChan:
|
||||
if err != nil {
|
||||
if routing.IsError(err, routing.ErrOutdated,
|
||||
routing.ErrIgnored) {
|
||||
if graph.IsError(err, graph.ErrOutdated,
|
||||
graph.ErrIgnored) {
|
||||
|
||||
log.Debugf("Router rejected "+
|
||||
log.Debugf("Graph rejected "+
|
||||
"AnnounceSignatures: %v", err)
|
||||
} else {
|
||||
log.Errorf("Unable to send channel "+
|
||||
@@ -4384,10 +4384,10 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
|
||||
select {
|
||||
case err := <-errChan:
|
||||
if err != nil {
|
||||
if routing.IsError(err, routing.ErrOutdated,
|
||||
routing.ErrIgnored) {
|
||||
if graph.IsError(err, graph.ErrOutdated,
|
||||
graph.ErrIgnored) {
|
||||
|
||||
log.Debugf("Router rejected "+
|
||||
log.Debugf("Graph rejected "+
|
||||
"NodeAnnouncement: %v", err)
|
||||
} else {
|
||||
log.Errorf("Unable to send node "+
|
||||
|
||||
Reference in new issue
Block a user