peer+htlcswitch: randomize link commitment fee updates

In this commit, we modify the behavior of links updating their
commitment fees. Rather than attempting to update the commitment fee for
each link every time a new block comes in, we'll use a timer with a
random interval between 10 and 60 minutes for each link to determine
when to update their corresponding commitment fee. This prevents us from
oscillating the fee rate for our various commitment transactions.
This commit is contained in:
Wilmer Paulino
2018-05-10 17:40:29 -04:00
parent c1a1b3ba3d
commit 4cc60493d2
4 changed files with 111 additions and 93 deletions

20
peer.go
View File

@@ -1,6 +1,7 @@
package main
import (
"bytes"
"container/list"
"fmt"
"net"
@@ -9,14 +10,11 @@ import (
"time"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/brontide"
"github.com/lightningnetwork/lnd/contractcourt"
"bytes"
"github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/brontide"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/contractcourt"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet"
@@ -551,11 +549,15 @@ func (p *peer) addLink(chanPoint *wire.OutPoint,
time.NewTicker(50 * time.Millisecond)),
FwdPkgGCTicker: htlcswitch.NewBatchTicker(
time.NewTicker(time.Minute)),
BatchSize: 10,
UnsafeReplay: cfg.UnsafeReplay,
BatchSize: 10,
UnsafeReplay: cfg.UnsafeReplay,
MinFeeUpdateTimeout: htlcswitch.DefaultMinLinkFeeUpdateTimeout,
MaxFeeUpdateTimeout: htlcswitch.DefaultMaxLinkFeeUpdateTimeout,
}
link := htlcswitch.NewChannelLink(linkCfg, lnChan,
uint32(currentHeight))
link := htlcswitch.NewChannelLink(
linkCfg, lnChan, uint32(currentHeight),
)
// With the channel link created, we'll now notify the htlc switch so
// this channel can be used to dispatch local payments and also