routing: if the graph has never been pruned, prune with current height

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-15 18:19:32 -08:00
parent 2b052cc889
commit f189e2395a
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 15 additions and 0 deletions

View File

@ -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
}