Reset failed routes once

pull/1/head
rkfg 2 years ago
parent cc815a60b5
commit 788f2b6bf7

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"log"
"math"
"math/rand"
"time"
@ -77,7 +78,16 @@ func min(args ...int64) (result int64) {
func (r *regolancer) pickChannelPair(amount int64) (from uint64, to uint64, maxAmount int64, err error) {
if len(r.channelPairs) == 0 {
return 0, 0, 0, errors.New("no routes")
if !r.routeFound {
return 0, 0, 0, errors.New("no routes")
}
log.Print(errColor("No channel pairs left, expiring all failed routes"))
// expire all failed routes
for k, v := range r.failureCache {
r.channelPairs[k] = v.channelPair
delete(r.failureCache, k)
}
r.routeFound = false
}
var fromChan, toChan *lnrpc.Channel
idx := rand.Int31n(int32(len(r.channelPairs)))

@ -64,6 +64,7 @@ type regolancer struct {
excludeBoth map[uint64]struct{}
excludeNodes [][]byte
statFilename string
routeFound bool
}
func loadConfig() {

@ -67,6 +67,7 @@ func (r *regolancer) getRoutes(ctx context.Context, from, to uint64, amtMsat int
if err != nil {
return nil, 0, err
}
r.routeFound = true
return routes.Routes, feeMsat, nil
}

Loading…
Cancel
Save