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:
parent
2b052cc889
commit
f189e2395a
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user