Skip to content

Commit 235eb5e

Browse files
committed
(commit to fixup) add publish delay
Make sure fee-rate is updated by loopout.go before the value is used by sweepbatcher.
1 parent a366205 commit 235eb5e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

client.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ var (
6262
// probeTimeout is the maximum time until a probe is allowed to take.
6363
probeTimeout = 3 * time.Minute
6464

65+
// repushDelay is the delay of (re)adding a sweep to sweepbatcher after
66+
// a block is mined.
6567
repushDelay = 1 * time.Second
6668

69+
// additionalDelay is the delay added on top of repushDelay inside the
70+
// sweepbatcher to publish a sweep transaction.
71+
additionalDelay = 1 * time.Second
72+
6773
// MinerFeeEstimationFailed is a magic number that is returned in a
6874
// quote call as the miner fee if the fee estimation in lnd's wallet
6975
// failed because of insufficient funds.
@@ -217,6 +223,17 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore,
217223
sweepbatcher.WithCustomFeeRate(
218224
loopOutSweepFeerateProvider.GetMinFeeRate,
219225
),
226+
227+
// Upon new block arrival, republishing is triggered in both
228+
// loopout.go code (waitForHtlcSpendConfirmedV2/ <-timerChan)
229+
// and in sweepbatcher code (batch.Run/case <-timerChan). The
230+
// former updates the fee rate which is used by the later by
231+
// calling AddSweep. Make sure they are ordered, add additional
232+
// delay time to sweepbatcher's handling. The delay used in
233+
// loopout.go is repushDelay.
234+
sweepbatcher.WithPublishDelay(
235+
repushDelay+additionalDelay,
236+
),
220237
)
221238

222239
executor = newExecutor(&executorConfig{

0 commit comments

Comments
 (0)