sweep: improve loggings

This commit is contained in:
yyforyongyu 2024-03-21 15:24:02 +08:00
parent 59526988cf
commit 106b97ce33
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
2 changed files with 22 additions and 11 deletions

View File

@ -132,13 +132,14 @@ func (r *BumpRequest) MaxFeeRateAllowed() (chainfee.SatPerKWeight, error) {
maxFeeRateAllowed := chainfee.NewSatPerKWeight(r.Budget, size) maxFeeRateAllowed := chainfee.NewSatPerKWeight(r.Budget, size)
if maxFeeRateAllowed > r.MaxFeeRate { if maxFeeRateAllowed > r.MaxFeeRate {
log.Debugf("Budget feerate %v exceeds MaxFeeRate %v, use "+ log.Debugf("Budget feerate %v exceeds MaxFeeRate %v, use "+
"MaxFeeRate instead", maxFeeRateAllowed, r.MaxFeeRate) "MaxFeeRate instead, txWeight=%v", maxFeeRateAllowed,
r.MaxFeeRate, size)
return r.MaxFeeRate, nil return r.MaxFeeRate, nil
} }
log.Debugf("Budget feerate %v below MaxFeeRate %v, use budget feerate "+ log.Debugf("Budget feerate %v below MaxFeeRate %v, use budget feerate "+
"instead", maxFeeRateAllowed, r.MaxFeeRate) "instead, txWeight=%v", maxFeeRateAllowed, r.MaxFeeRate, size)
return maxFeeRateAllowed, nil return maxFeeRateAllowed, nil
} }
@ -361,6 +362,10 @@ func (t *TxPublisher) initializeFeeFunction(
// Get the initial conf target. // Get the initial conf target.
confTarget := calcCurrentConfTarget(t.currentHeight, req.DeadlineHeight) confTarget := calcCurrentConfTarget(t.currentHeight, req.DeadlineHeight)
log.Debugf("Initializing fee function with conf target=%v, budget=%v, "+
"maxFeeRateAllowed=%v", confTarget, req.Budget,
maxFeeRateAllowed)
// Initialize the fee function and return it. // Initialize the fee function and return it.
// //
// TODO(yy): return based on differet req.Strategy? // TODO(yy): return based on differet req.Strategy?

View File

@ -84,13 +84,19 @@ type ParamsUpdate struct {
// String returns a human readable interpretation of the sweep parameters. // String returns a human readable interpretation of the sweep parameters.
func (p Params) String() string { func (p Params) String() string {
deadline := "none"
p.DeadlineHeight.WhenSome(func(d int32) {
deadline = fmt.Sprintf("%d", d)
})
exclusiveGroup := "none"
if p.ExclusiveGroup != nil { if p.ExclusiveGroup != nil {
return fmt.Sprintf("fee=%v, force=%v, exclusive_group=%v", exclusiveGroup = fmt.Sprintf("%d", *p.ExclusiveGroup)
p.Fee, p.Force, *p.ExclusiveGroup)
} }
return fmt.Sprintf("fee=%v, force=%v, exclusive_group=nil", return fmt.Sprintf("fee=%v, force=%v, exclusive_group=%v, budget=%v, "+
p.Fee, p.Force) "deadline=%v", p.Fee, p.Force, exclusiveGroup, p.Budget,
deadline)
} }
// SweepState represents the current state of a pending input. // SweepState represents the current state of a pending input.
@ -518,10 +524,10 @@ func (s *UtxoSweeper) SweepInput(input input.Input,
absoluteTimeLock, _ := input.RequiredLockTime() absoluteTimeLock, _ := input.RequiredLockTime()
log.Infof("Sweep request received: out_point=%v, witness_type=%v, "+ log.Infof("Sweep request received: out_point=%v, witness_type=%v, "+
"relative_time_lock=%v, absolute_time_lock=%v, amount=%v, "+ "relative_time_lock=%v, absolute_time_lock=%v, amount=%v, "+
"parent=(%v), params=(%v)", input.OutPoint(), "parent=(%v), params=(%v), currentHeight=%v", input.OutPoint(),
input.WitnessType(), input.BlocksToMaturity(), absoluteTimeLock, input.WitnessType(), input.BlocksToMaturity(), absoluteTimeLock,
btcutil.Amount(input.SignDesc().Output.Value), btcutil.Amount(input.SignDesc().Output.Value),
input.UnconfParent(), params) input.UnconfParent(), params, s.currentHeight)
sweeperInput := &sweepInputMessage{ sweeperInput := &sweepInputMessage{
input: input, input: input,
@ -1667,9 +1673,9 @@ func (s *UtxoSweeper) handleBumpEventTxReplaced(r *BumpResult) error {
return err return err
} }
log.Infof("RBFed tx=%v(fee=%v, feerate=%v) with new tx=%v(fee=%v, "+ log.Infof("RBFed tx=%v(fee=%v sats, feerate=%v sats/kw) with new "+
"feerate=%v)", record.Txid, record.Fee, record.FeeRate, "tx=%v(fee=%v, "+"feerate=%v)", record.Txid, record.Fee,
tr.Txid, tr.Fee, tr.FeeRate) record.FeeRate, tr.Txid, tr.Fee, tr.FeeRate)
// The old sweeping tx has been replaced by a new one, we will update // The old sweeping tx has been replaced by a new one, we will update
// the tx record in the sweeper db. // the tx record in the sweeper db.