Merge pull request #8961 from yyforyongyu/fix-leaseoutput

Improve the performace of `LeaseOutput`
This commit is contained in:
Olaoluwa Osuntokun
2024-08-21 16:31:26 -07:00
committed by GitHub
20 changed files with 100 additions and 87 deletions

View File

@@ -56,7 +56,13 @@ func lockInputs(w lnwallet.WalletController,
},
}
expiration, pkScript, value, err := w.LeaseOutput(
// Get the details about this outpoint.
utxo, err := w.FetchOutpointInfo(&lock.Outpoint)
if err != nil {
return nil, fmt.Errorf("fetch outpoint info: %w", err)
}
expiration, err := w.LeaseOutput(
lock.LockID, lock.Outpoint,
chanfunding.DefaultLockDuration,
)
@@ -80,8 +86,8 @@ func lockInputs(w lnwallet.WalletController,
}
lock.Expiration = expiration
lock.PkScript = pkScript
lock.Value = int64(value)
lock.PkScript = utxo.PkScript
lock.Value = int64(utxo.Value)
locks[idx] = lock
}

View File

@@ -496,7 +496,7 @@ func (w *WalletKit) LeaseOutput(ctx context.Context,
// other concurrent processes attempting to lease the same UTXO.
var expiration time.Time
err = w.cfg.CoinSelectionLocker.WithCoinSelectLock(func() error {
expiration, _, _, err = w.cfg.Wallet.LeaseOutput(
expiration, err = w.cfg.Wallet.LeaseOutput(
lockID, *op, duration,
)
return err
@@ -1296,7 +1296,7 @@ func (w *WalletKit) sweepNewInput(op *wire.OutPoint, currentHeight uint32,
//
// We'll gather all of the information required by the UtxoSweeper in
// order to sweep the output.
utxo, err := w.cfg.Wallet.FetchInputInfo(op)
utxo, err := w.cfg.Wallet.FetchOutpointInfo(op)
if err != nil {
return err
}