sweep+itest: return next retry fee rate in TxFailed event
We now return the next retry fee rate in `TxFailed` event in `TxPublisher`. When handling the event, `UtxoSweeper` will update the inputs to make sure the starting fee rate is set before attempting the next sweep.
This commit is contained in:
4 files changed
+82
-38
No files matched your search
+16
-11
@@ -951,7 +951,9 @@ func (s *UtxoSweeper) markInputsPublished(tr *TxRecord, set InputSet) error {
|
||||
}
|
||||
|
||||
// markInputsPublishFailed marks the list of inputs as failed to be published.
|
||||
func (s *UtxoSweeper) markInputsPublishFailed(set InputSet) {
|
||||
func (s *UtxoSweeper) markInputsPublishFailed(set InputSet,
|
||||
feeRate chainfee.SatPerKWeight) {
|
||||
|
||||
// Reschedule sweep.
|
||||
for _, inp := range set.Inputs() {
|
||||
op := inp.OutPoint()
|
||||
@@ -978,6 +980,15 @@ func (s *UtxoSweeper) markInputsPublishFailed(set InputSet) {
|
||||
|
||||
// Update the input's state.
|
||||
pi.state = PublishFailed
|
||||
|
||||
log.Debugf("Input(%v): updating params: starting fee rate "+
|
||||
"[%v -> %v]", op, pi.params.StartingFeeRate,
|
||||
feeRate)
|
||||
|
||||
// Update the input using the fee rate specified from the
|
||||
// BumpResult, which should be the starting fee rate to use for
|
||||
// the next sweeping attempt.
|
||||
pi.params.StartingFeeRate = fn.Some(feeRate)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1699,7 +1710,7 @@ func (s *UtxoSweeper) handleBumpEventTxFailed(resp *bumpResp) {
|
||||
// the inputs specified by the set.
|
||||
//
|
||||
// TODO(yy): should we also remove the failed tx from db?
|
||||
s.markInputsPublishFailed(resp.set)
|
||||
s.markInputsPublishFailed(resp.set, resp.result.FeeRate)
|
||||
}
|
||||
|
||||
// handleBumpEventTxReplaced handles the case where the sweeping tx has been
|
||||
@@ -1948,7 +1959,7 @@ func (s *UtxoSweeper) handleUnknownSpendTx(inp *SweeperInput, tx *wire.MsgTx) {
|
||||
func (s *UtxoSweeper) handleBumpEventTxUnknownSpend(r *bumpResp) {
|
||||
// Mark the inputs as publish failed, which means they will be retried
|
||||
// later.
|
||||
s.markInputsPublishFailed(r.set)
|
||||
s.markInputsPublishFailed(r.set, r.result.FeeRate)
|
||||
|
||||
// Get all the inputs that are not spent in the current sweeping tx.
|
||||
spentInputs := r.result.SpentInputs
|
||||
@@ -1982,15 +1993,9 @@ func (s *UtxoSweeper) handleBumpEventTxUnknownSpend(r *bumpResp) {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debugf("Input(%v): updating params: starting fee rate "+
|
||||
"[%v -> %v], immediate [%v -> true]", op,
|
||||
input.params.StartingFeeRate, r.result.FeeRate,
|
||||
input.params.Immediate)
|
||||
log.Debugf("Input(%v): updating params: immediate [%v -> true]",
|
||||
op, r.result.FeeRate, input.params.Immediate)
|
||||
|
||||
// Update the input using the fee rate specified from the
|
||||
// BumpResult, which should be the starting fee rate to use for
|
||||
// the next sweeping attempt.
|
||||
input.params.StartingFeeRate = fn.Some(r.result.FeeRate)
|
||||
input.params.Immediate = true
|
||||
inputsToRetry = append(inputsToRetry, input)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user