From f189e2395acff78213dbea2a241ff651f99e7e2b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 15 Nov 2017 18:19:32 -0800 Subject: [PATCH] routing: if the graph has never been pruned, prune with current height MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit we ensure that if this is the first time that the ChannelRouter is starting, then we set the pruned height+hash to the current best height. Otherwise, it’s possible that we attempt to update the filter with a 0 prune height, which will restart a historical rescan unnecessarily. --- routing/router.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/routing/router.go b/routing/router.go index 46f5bd5c0..edf956343 100644 --- a/routing/router.go +++ b/routing/router.go @@ -279,7 +279,22 @@ func (r *ChannelRouter) Start() error { // If the graph has never been pruned, or hasn't fully been // created yet, then we don't treat this as an explicit error. case err == channeldb.ErrGraphNeverPruned: + fallthrough case err == channeldb.ErrGraphNotFound: + // If the graph has never been pruned, then we'll set + // the prune height to the current best height of the + // chain backend. + bestHash, bestHeight, err := r.cfg.Chain.GetBestBlock() + if err != nil { + return err + } + + _, err = r.cfg.Graph.PruneGraph( + nil, bestHash, uint32(bestHeight), + ) + if err != nil { + return err + } default: return err }