add failtolerance also for probing

pull/22/head
ziggie 2 years ago
parent 01d8eff230
commit aec13d068b
No known key found for this signature in database
GPG Key ID: 61D302CA09A9C7B5

@ -0,0 +1,10 @@
package main
func absoluteDeltaPPM(base, amt int64) (deltaPPM int64) {
deltaPPM = (base - amt) * 1e6 / base
if deltaPPM < 0 {
return -deltaPPM
}
return deltaPPM
}

@ -47,7 +47,7 @@ type configParams struct {
Exclude []string `long:"exclude" description:"don't use this node or your channel for routing (can be specified multiple times)" json:"exclude" toml:"exclude"`
To []string `long:"to" description:"try only this channel or node as target (should satisfy other constraints too; can be specified multiple times)" json:"to" toml:"to"`
From []string `long:"from" description:"try only this channel or node as source (should satisfy other constraints too; can be specified multiple times)" json:"from" toml:"from"`
FailTolerance int64 `long:"fail-tolerance" description:"if a channel failed before during this rebalance but chosen again by lnd, and the forward amount differs by less than this ppm, exclude the channel" json:"fail_tolerance" toml:"fail_tolerance"`
FailTolerance int64 `long:"fail-tolerance" description:"a payment that differs from the prior attempt by this ppm will be cancelled" json:"fail_tolerance" toml:"fail_tolerance"`
AllowUnbalanceFrom bool `long:"allow-unbalance-from" description:"let the source channel go below 50% local liquidity, use if you want to drain a channel; you should also set --pfrom to >50" json:"allow_unbalance_from" toml:"allow_unbalance_from"`
AllowUnbalanceTo bool `long:"allow-unbalance-to" description:"let the target channel go above 50% local liquidity, use if you want to refill a channel; you should also set --pto to >50" json:"allow_unbalance_to" toml:"allow_unbalance_to"`
StatFilename string `short:"s" long:"stat" description:"save successful rebalance information to the specified CSV file" json:"stat" toml:"stat"`
@ -374,6 +374,7 @@ func preflightChecks(params *configParams) error {
if params.FailTolerance == 0 {
params.FailTolerance = 1000
}
if (params.RelAmountFrom > 0 || params.RelAmountTo > 0) && params.AllowRapidRebalance {
return fmt.Errorf("use either relative amounts or rapid rebalance but not both")

@ -15,7 +15,7 @@ func (r *regolancer) validateRoute(route *lnrpc.Route) error {
prevHopPK := r.myPK
for _, h := range route.Hops {
hopPK := h.PubKey
if fp, ok := r.mcCache[prevHopPK+hopPK]; ok && 1e6-h.AmtToForwardMsat*1e6/fp < params.FailTolerance {
if fp, ok := r.mcCache[prevHopPK+hopPK]; ok && absoluteDeltaPPM(fp, h.AmtToForwardMsat) < params.FailTolerance {
from, err := hex.DecodeString(prevHopPK)
if err != nil {
return err

@ -195,7 +195,8 @@ func (r *regolancer) rebuildRoute(ctx context.Context, route *lnrpc.Route, amoun
func (r *regolancer) probeRoute(ctx context.Context, route *lnrpc.Route,
goodAmount, badAmount, amount int64, steps int) (maxAmount int64, err error) {
if amount == badAmount || amount == goodAmount || amount == -goodAmount {
if absoluteDeltaPPM(badAmount, amount) <= params.FailTolerance || absoluteDeltaPPM(amount, goodAmount) <= params.FailTolerance || amount == -goodAmount {
bestAmount := hiWhiteColor(goodAmount)
if goodAmount <= 0 {
bestAmount = hiWhiteColor("unknown")

Loading…
Cancel
Save