routing: invalidate routing cache on each new block
This commit makes the routing cache invalidation a bit more aggressive. We now invalidate the cache on each new block as the routes in the cache are based on the current block height. Using the cached items may cause our routes to fail due to them having time locks which have already expired.
This commit is contained in:
1 file changed
+12
-7
+12
-7
@@ -465,17 +465,22 @@ func (r *ChannelRouter) networkHandler() {
|
|||||||
log.Infof("Block %v (height=%v) closed %v channels",
|
log.Infof("Block %v (height=%v) closed %v channels",
|
||||||
chainUpdate.Hash, blockHeight, len(chansClosed))
|
chainUpdate.Hash, blockHeight, len(chansClosed))
|
||||||
|
|
||||||
if len(chansClosed) == 0 {
|
// Invalidate the route cache as the block height has
|
||||||
continue
|
// changed which will invalidate the HTLC timeouts we
|
||||||
}
|
// have crafted within each of the pre-computed routes.
|
||||||
|
//
|
||||||
// Invalidate the route cache as channels within the
|
// TODO(roasbeef): need to invalidate after each
|
||||||
// graph have closed, which may affect our choice of
|
// chan ann update?
|
||||||
// the KSP's for a particular routeTuple.
|
// * can have map of chanID to routes involved, avoids
|
||||||
|
// full invalidation
|
||||||
r.routeCacheMtx.Lock()
|
r.routeCacheMtx.Lock()
|
||||||
r.routeCache = make(map[routeTuple][]*Route)
|
r.routeCache = make(map[routeTuple][]*Route)
|
||||||
r.routeCacheMtx.Unlock()
|
r.routeCacheMtx.Unlock()
|
||||||
|
|
||||||
|
if len(chansClosed) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Notify all currently registered clients of the newly
|
// Notify all currently registered clients of the newly
|
||||||
// closed channels.
|
// closed channels.
|
||||||
closeSummaries := createCloseSummaries(blockHeight, chansClosed...)
|
closeSummaries := createCloseSummaries(blockHeight, chansClosed...)
|
||||||
|
|||||||
Reference in new issue
Block a user