Skip to content

Commit 121116c

Browse files
committed
sweep: remove dead code and add better logging
1 parent 50bc191 commit 121116c

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

chainntnfs/mempool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (m *MempoolNotifier) findRelevantInputs(tx *btcutil.Tx) (inputsWithTx,
211211

212212
// If found, save it to watchedInputs to notify the
213213
// subscriber later.
214-
Log.Infof("Found input %s, spent in %s", op, txid)
214+
Log.Debugf("Found input %s, spent in %s", op, txid)
215215

216216
// Construct the spend details.
217217
details := &SpendDetail{

sweep/fee_bumper.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,6 @@ func (t *TxPublisher) processRecords() {
972972
// For records that are confirmed, we'll notify the caller about this
973973
// result.
974974
for _, r := range confirmedRecords {
975-
log.Debugf("Tx=%v is confirmed", r.tx.TxHash())
976975
t.wg.Add(1)
977976
go t.handleTxConfirmed(r)
978977
}
@@ -982,16 +981,13 @@ func (t *TxPublisher) processRecords() {
982981

983982
// For records that are not confirmed, we perform a fee bump if needed.
984983
for _, r := range feeBumpRecords {
985-
log.Debugf("Attempting to fee bump Tx=%v", r.tx.TxHash())
986984
t.wg.Add(1)
987985
go t.handleFeeBumpTx(r, currentHeight)
988986
}
989987

990988
// For records that are failed, we'll notify the caller about this
991989
// result.
992990
for _, r := range failedRecords {
993-
log.Debugf("Tx=%v has inputs been spent by a third party, "+
994-
"failing it now", r.tx.TxHash())
995991
t.wg.Add(1)
996992
go t.handleThirdPartySpent(r)
997993
}
@@ -1004,6 +1000,8 @@ func (t *TxPublisher) processRecords() {
10041000
func (t *TxPublisher) handleTxConfirmed(r *monitorRecord) {
10051001
defer t.wg.Done()
10061002

1003+
log.Debugf("Record %v is spent in tx=%v", r.requestID, r.tx.TxHash())
1004+
10071005
// Create a result that will be sent to the resultChan which is
10081006
// listened by the caller.
10091007
result := &BumpResult{
@@ -1113,6 +1111,9 @@ func (t *TxPublisher) handleInitialBroadcast(r *monitorRecord) {
11131111
func (t *TxPublisher) handleFeeBumpTx(r *monitorRecord, currentHeight int32) {
11141112
defer t.wg.Done()
11151113

1114+
log.Debugf("Attempting to fee bump tx=%v in record %v", r.tx.TxHash(),
1115+
r.requestID)
1116+
11161117
oldTxid := r.tx.TxHash()
11171118

11181119
// Get the current conf target for this record.
@@ -1158,6 +1159,10 @@ func (t *TxPublisher) handleFeeBumpTx(r *monitorRecord, currentHeight int32) {
11581159
func (t *TxPublisher) handleThirdPartySpent(r *monitorRecord) {
11591160
defer t.wg.Done()
11601161

1162+
log.Debugf("Record %v has inputs spent by a tx unknown to the fee "+
1163+
"bumper, failing it now:\n%v", r.requestID,
1164+
inputTypeSummary(r.req.Inputs))
1165+
11611166
// Create a result that will be sent to the resultChan which is
11621167
// listened by the caller.
11631168
result := &BumpResult{
@@ -1272,17 +1277,6 @@ func (t *TxPublisher) createAndPublishTx(
12721277
return fn.Some(*result)
12731278
}
12741279

1275-
// isConfirmed checks the btcwallet to see whether the tx is confirmed.
1276-
func (t *TxPublisher) isConfirmed(txid chainhash.Hash) bool {
1277-
details, err := t.cfg.Wallet.GetTransactionDetails(&txid)
1278-
if err != nil {
1279-
log.Warnf("Failed to get tx details for %v: %v", txid, err)
1280-
return false
1281-
}
1282-
1283-
return details.NumConfirmations > 0
1284-
}
1285-
12861280
// isThirdPartySpent checks whether the inputs of the tx has already been spent
12871281
// by a third party. When a tx is not confirmed, yet its inputs has been spent,
12881282
// then it must be spent by a different tx other than the sweeping tx here.

0 commit comments

Comments
 (0)