Merge pull request #407 from cfromknecht/router-prevent-rescan
router: prevent rescan on startup
This commit is contained in:
commit
06f82474d4
@ -366,12 +366,12 @@ func (b *BtcdFilteredChainView) chainFilterer() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no block was returned from the rescan,
|
// If no block was returned from the rescan, it
|
||||||
// it means no maching transactions were found.
|
// means no matching transactions were found.
|
||||||
if len(rescanned) != 1 {
|
if len(rescanned) != 1 {
|
||||||
log.Debugf("no matching block found "+
|
log.Tracef("rescan of block %v at "+
|
||||||
"for rescan of hash %v",
|
"height=%d yielded no "+
|
||||||
blockHash)
|
"transactions", blockHash, i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
decoded, err := decodeJSONBlock(
|
decoded, err := decodeJSONBlock(
|
||||||
|
@ -273,6 +273,18 @@ func (r *ChannelRouter) Start() error {
|
|||||||
r.newBlocks = r.cfg.ChainView.FilteredBlocks()
|
r.newBlocks = r.cfg.ChainView.FilteredBlocks()
|
||||||
r.staleBlocks = r.cfg.ChainView.DisconnectedBlocks()
|
r.staleBlocks = r.cfg.ChainView.DisconnectedBlocks()
|
||||||
|
|
||||||
|
_, pruneHeight, err := r.cfg.Graph.PruneTip()
|
||||||
|
if err != nil {
|
||||||
|
switch {
|
||||||
|
// 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:
|
||||||
|
case err == channeldb.ErrGraphNotFound:
|
||||||
|
default:
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Before we perform our manual block pruning, we'll construct and
|
// Before we perform our manual block pruning, we'll construct and
|
||||||
// apply a fresh chain filter to the active FilteredChainView instance.
|
// apply a fresh chain filter to the active FilteredChainView instance.
|
||||||
// We do this before, as otherwise we may miss on-chain events as the
|
// We do this before, as otherwise we may miss on-chain events as the
|
||||||
@ -281,8 +293,9 @@ func (r *ChannelRouter) Start() error {
|
|||||||
if err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
if err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Filtering chain using %v channels active", len(channelView))
|
log.Infof("Filtering chain using %v channels active", len(channelView))
|
||||||
err = r.cfg.ChainView.UpdateFilter(channelView, r.bestHeight)
|
err = r.cfg.ChainView.UpdateFilter(channelView, pruneHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -331,6 +344,7 @@ func (r *ChannelRouter) syncGraphWithChain() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.bestHeight = uint32(bestHeight)
|
r.bestHeight = uint32(bestHeight)
|
||||||
|
|
||||||
pruneHash, pruneHeight, err := r.cfg.Graph.PruneTip()
|
pruneHash, pruneHeight, err := r.cfg.Graph.PruneTip()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
|
Loading…
Reference in New Issue
Block a user