Skip to content

Commit 6c62ded

Browse files
committed
loopout: remove dead code
The first result of function sweepConfTarget was not used. The function was renamed to canSweep to better reflect what it does.
1 parent 9c347b4 commit 6c62ded

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

loopout.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,12 +1169,12 @@ func (s *loopOutSwap) waitForHtlcSpendConfirmedV2(globalCtx context.Context,
11691169
timerChan = s.timerFactory(repushDelay)
11701170

11711171
case <-timerChan:
1172-
// sweepConfTarget will return false if the preimage is
1172+
// canSweep will return false if the preimage is
11731173
// not revealed yet but the conf target is closer than
11741174
// 20 blocks. In this case to be sure we won't attempt
11751175
// to sweep at all and we won't reveal the preimage
11761176
// either.
1177-
_, canSweep := s.sweepConfTarget()
1177+
canSweep := s.canSweep()
11781178
if !canSweep {
11791179
s.log.Infof("Aborting swap, timed " +
11801180
"out on-chain")
@@ -1375,9 +1375,9 @@ func validateLoopOutContract(lnd *lndclient.LndServices, request *OutRequest,
13751375
return nil
13761376
}
13771377

1378-
// sweepConfTarget returns the confirmation target for the htlc sweep or false
1379-
// if we're too late.
1380-
func (s *loopOutSwap) sweepConfTarget() (int32, bool) {
1378+
// canSweep will return false if the preimage is not revealed yet but the conf
1379+
// target is closer than 20 blocks (i.e. it is too late to reveal the preimage).
1380+
func (s *loopOutSwap) canSweep() bool {
13811381
remainingBlocks := s.CltvExpiry - s.height
13821382
blocksToLastReveal := remainingBlocks - MinLoopOutPreimageRevealDelta
13831383
preimageRevealed := s.state == loopdb.StatePreimageRevealed
@@ -1393,20 +1393,8 @@ func (s *loopOutSwap) sweepConfTarget() (int32, bool) {
13931393
s.height)
13941394

13951395
s.state = loopdb.StateFailTimeout
1396-
return 0, false
1396+
return false
13971397
}
13981398

1399-
// Calculate the transaction fee based on the confirmation target
1400-
// required to sweep the HTLC before the timeout. We'll use the
1401-
// confirmation target provided by the client unless we've come too
1402-
// close to the expiration height, in which case we'll use the default
1403-
// if it is better than what the client provided.
1404-
confTarget := s.SweepConfTarget
1405-
if remainingBlocks <= DefaultSweepConfTargetDelta &&
1406-
confTarget > DefaultSweepConfTarget {
1407-
1408-
confTarget = DefaultSweepConfTarget
1409-
}
1410-
1411-
return confTarget, true
1399+
return true
14121400
}

0 commit comments

Comments
 (0)