From f8cbe34e936049a1ef0695bd91d12a021d397383 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 21 Jul 2018 19:52:21 -0700 Subject: [PATCH] routing: prune nodes from the channel graph on start up --- routing/router.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/routing/router.go b/routing/router.go index 4d62de286..de4653258 100644 --- a/routing/router.go +++ b/routing/router.go @@ -9,6 +9,9 @@ import ( "sync/atomic" "time" + "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcutil" "github.com/coreos/bbolt" "github.com/davecgh/go-spew/spew" "github.com/lightningnetwork/lnd/channeldb" @@ -17,9 +20,6 @@ import ( "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/multimutex" "github.com/lightningnetwork/lnd/routing/chainview" - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" "crypto/sha256" @@ -382,6 +382,13 @@ func (r *ChannelRouter) Start() error { return err } + // Finally, before we proceed, we'll prune any unconnected nodes from + // the graph in order to ensure we maintain a tight graph of "useful" + // nodes. + if err := r.cfg.Graph.PruneGraphNodes(); err != nil { + return err + } + r.wg.Add(1) go r.networkHandler()