Merge pull request #1482 from cfromknecht/uniform-fee-update-timeout
htlcswitch/link: correct bias in fee update backoff
This commit is contained in:
commit
0a045f8651
@ -995,12 +995,7 @@ out:
|
||||
func (l *channelLink) randomFeeUpdateTimeout() time.Duration {
|
||||
lower := int64(l.cfg.MinFeeUpdateTimeout)
|
||||
upper := int64(l.cfg.MaxFeeUpdateTimeout)
|
||||
rand := prand.Int63n(upper)
|
||||
if rand < lower {
|
||||
rand = lower
|
||||
}
|
||||
|
||||
return time.Duration(rand)
|
||||
return time.Duration(prand.Int63n(upper-lower) + lower)
|
||||
}
|
||||
|
||||
// handleDownStreamPkt processes an HTLC packet sent from the downstream HTLC
|
||||
|
@ -1497,7 +1497,7 @@ func newSingleLinkTestHarness(chanAmt, chanReserve btcutil.Amount) (
|
||||
// to not trigger commit updates automatically during tests.
|
||||
BatchSize: 10000,
|
||||
MinFeeUpdateTimeout: 30 * time.Minute,
|
||||
MaxFeeUpdateTimeout: 30 * time.Minute,
|
||||
MaxFeeUpdateTimeout: 40 * time.Minute,
|
||||
}
|
||||
|
||||
const startingHeight = 100
|
||||
@ -3878,7 +3878,7 @@ func restartLink(aliceChannel *lnwallet.LightningChannel, aliceSwitch *Switch,
|
||||
// to not trigger commit updates automatically during tests.
|
||||
BatchSize: 10000,
|
||||
MinFeeUpdateTimeout: 30 * time.Minute,
|
||||
MaxFeeUpdateTimeout: 30 * time.Minute,
|
||||
MaxFeeUpdateTimeout: 40 * time.Minute,
|
||||
// Set any hodl flags requested for the new link.
|
||||
HodlMask: hodl.MaskFromFlags(hodlFlags...),
|
||||
DebugHTLC: len(hodlFlags) > 0,
|
||||
|
@ -878,9 +878,10 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
}
|
||||
|
||||
const (
|
||||
batchTimeout = 50 * time.Millisecond
|
||||
fwdPkgTimeout = 5 * time.Second
|
||||
feeUpdateTimeout = 30 * time.Minute
|
||||
batchTimeout = 50 * time.Millisecond
|
||||
fwdPkgTimeout = 5 * time.Second
|
||||
minFeeUpdateTimeout = 30 * time.Minute
|
||||
maxFeeUpdateTimeout = 40 * time.Minute
|
||||
)
|
||||
|
||||
pCache := &mockPreimageCache{
|
||||
@ -919,8 +920,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
BatchSize: 10,
|
||||
BatchTicker: &mockTicker{time.NewTicker(batchTimeout).C},
|
||||
FwdPkgGCTicker: &mockTicker{time.NewTicker(fwdPkgTimeout).C},
|
||||
MinFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MinFeeUpdateTimeout: minFeeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: maxFeeUpdateTimeout,
|
||||
OnChannelFailure: func(lnwire.ChannelID, lnwire.ShortChannelID, LinkFailureError) {},
|
||||
},
|
||||
aliceChannel,
|
||||
@ -962,8 +963,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
BatchSize: 10,
|
||||
BatchTicker: &mockTicker{time.NewTicker(batchTimeout).C},
|
||||
FwdPkgGCTicker: &mockTicker{time.NewTicker(fwdPkgTimeout).C},
|
||||
MinFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MinFeeUpdateTimeout: minFeeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: maxFeeUpdateTimeout,
|
||||
OnChannelFailure: func(lnwire.ChannelID, lnwire.ShortChannelID, LinkFailureError) {},
|
||||
},
|
||||
firstBobChannel,
|
||||
@ -1005,8 +1006,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
BatchSize: 10,
|
||||
BatchTicker: &mockTicker{time.NewTicker(batchTimeout).C},
|
||||
FwdPkgGCTicker: &mockTicker{time.NewTicker(fwdPkgTimeout).C},
|
||||
MinFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MinFeeUpdateTimeout: minFeeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: maxFeeUpdateTimeout,
|
||||
OnChannelFailure: func(lnwire.ChannelID, lnwire.ShortChannelID, LinkFailureError) {},
|
||||
},
|
||||
secondBobChannel,
|
||||
@ -1048,8 +1049,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
BatchSize: 10,
|
||||
BatchTicker: &mockTicker{time.NewTicker(batchTimeout).C},
|
||||
FwdPkgGCTicker: &mockTicker{time.NewTicker(fwdPkgTimeout).C},
|
||||
MinFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: feeUpdateTimeout,
|
||||
MinFeeUpdateTimeout: minFeeUpdateTimeout,
|
||||
MaxFeeUpdateTimeout: maxFeeUpdateTimeout,
|
||||
OnChannelFailure: func(lnwire.ChannelID, lnwire.ShortChannelID, LinkFailureError) {},
|
||||
},
|
||||
carolChannel,
|
||||
|
Loading…
Reference in New Issue
Block a user