Skip to content

Commit 730bc75

Browse files
committed
proof: include courier address in backoff log messages
If the proof transfer backoff procedure is long-running, user-shared logs may lack the original courier address, containing only retry log entries. This change ensures that backoff log messages also include the courier address, aiding troubleshooting.
1 parent 632294a commit 730bc75

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

proof/courier.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import (
55
"context"
66
"crypto/sha512"
77
"crypto/tls"
8+
"encoding/hex"
89
"fmt"
910
"net/url"
1011
"sync"
1112
"time"
1213

1314
"github.com/btcsuite/btcd/btcec/v2"
15+
"github.com/btcsuite/btclog/v2"
1416
"github.com/lightninglabs/lightning-node-connect/hashmailrpc"
1517
"github.com/lightninglabs/taproot-assets/asset"
1618
"github.com/lightninglabs/taproot-assets/fn"
@@ -676,9 +678,9 @@ func (b *BackoffHandler) Exec(ctx context.Context, proofLocator Locator,
676678
if err != nil {
677679
return err
678680
}
679-
log.Infof("Starting proof transfer backoff procedure "+
680-
"(transfer_type=%s, locator_hash=%x)", transferType,
681-
locatorHash[:])
681+
log.InfoS(ctx, "Starting proof transfer backoff procedure",
682+
"transfer_type", transferType, "locator_hash",
683+
hex.EncodeToString(locatorHash[:]))
682684

683685
// Conditionally perform an initial delay based on the transfer log to
684686
// ensure that we don't spam the courier service with proof transfer
@@ -708,7 +710,7 @@ func (b *BackoffHandler) Exec(ctx context.Context, proofLocator Locator,
708710
"attempt: %w", err)
709711
}
710712

711-
// Execute target proof transfer function.
713+
// Execute the target proof transfer function.
712714
errExec = transferFunc()
713715
if errExec == nil {
714716
// The target function executed successfully, we can
@@ -732,10 +734,10 @@ func (b *BackoffHandler) Exec(ctx context.Context, proofLocator Locator,
732734
)
733735
subscriberEvent(waitEvent)
734736

735-
log.Debugf("Proof transfer failed with error. Backing off. "+
736-
"(transfer_type=%s, locator_hash=%x, backoff=%s, "+
737-
"attempt=%d): %v",
738-
transferType, locatorHash[:], backoff, i, errExec)
737+
log.DebugS(ctx, "Backing off: proof transfer failed",
738+
"transfer_type", transferType, "locator_hash",
739+
hex.EncodeToString(locatorHash[:]), "backoff", backoff,
740+
"attempt", i, "err", errExec)
739741

740742
// Wait before reattempting execution.
741743
err := b.wait(ctx, backoff)
@@ -976,8 +978,10 @@ func (h *HashMailCourier) DeliverProof(ctx context.Context, recipient Recipient,
976978

977979
return nil
978980
}
981+
982+
backoffCtx := btclog.WithCtx(ctx, "addr", h.addr.String())
979983
err := h.backoffHandle.Exec(
980-
ctx, proof.Locator, SendTransferType, deliveryExec,
984+
backoffCtx, proof.Locator, SendTransferType, deliveryExec,
981985
h.publishSubscriberEvent,
982986
)
983987
if err != nil {
@@ -1550,8 +1554,10 @@ func (c *UniverseRpcCourier) DeliverProof(ctx context.Context,
15501554

15511555
return nil
15521556
}
1557+
1558+
backoffCtx := btclog.WithCtx(ctx, "addr", c.addr.String())
15531559
err = c.backoffHandle.Exec(
1554-
ctx, loc, SendTransferType, deliverFunc,
1560+
backoffCtx, loc, SendTransferType, deliverFunc,
15551561
c.publishSubscriberEvent,
15561562
)
15571563
if err != nil {
@@ -1626,8 +1632,10 @@ func (c *UniverseRpcCourier) ReceiveProof(ctx context.Context,
16261632

16271633
return nil
16281634
}
1635+
1636+
backoffCtx := btclog.WithCtx(ctx, "addr", c.addr.String())
16291637
err := c.backoffHandle.Exec(
1630-
ctx, loc, ReceiveTransferType, receiveFunc,
1638+
backoffCtx, loc, ReceiveTransferType, receiveFunc,
16311639
c.publishSubscriberEvent,
16321640
)
16331641
if err != nil {

0 commit comments

Comments
 (0)