@@ -11,6 +11,7 @@ import (
1111 "time"
1212
1313 "github.com/btcsuite/btcd/btcec/v2"
14+ "github.com/btcsuite/btclog/v2"
1415 "github.com/lightninglabs/lightning-node-connect/hashmailrpc"
1516 "github.com/lightninglabs/taproot-assets/asset"
1617 "github.com/lightninglabs/taproot-assets/fn"
@@ -613,12 +614,12 @@ func (b *BackoffHandler) initialDelay(ctx context.Context,
613614 return nil
614615 }
615616
616- locatorHash , err := proofLocator .Hash ()
617+ locatorStr , err := proofLocator .LogString ()
617618 if err != nil {
618619 return err
619620 }
620- log .Debugf ( "Handling initial proof transfer delay (locator_hash=%x) " ,
621- locatorHash [:] )
621+ log .DebugS ( ctx , "Handling initial proof transfer delay" , "locator " ,
622+ locatorStr )
622623
623624 // Query delivery log to ensure a sensible rate of delivery attempts.
624625 timestamps , err := b .transferLog .QueryProofTransferLog (
@@ -630,8 +631,8 @@ func (b *BackoffHandler) initialDelay(ctx context.Context,
630631 }
631632
632633 if len (timestamps ) == 0 {
633- log .Debugf ( "No previous transfer attempts found for proof " +
634- "(locator_hash=%x) " , locatorHash [:] )
634+ log .DebugS ( ctx , "No previous transfer attempts found for proof" ,
635+ "locator " , locatorStr )
635636 return nil
636637 }
637638
@@ -648,9 +649,9 @@ func (b *BackoffHandler) initialDelay(ctx context.Context,
648649 backoffResetWait := b .cfg .BackoffResetWait
649650 if timeSinceLastAttempt < backoffResetWait {
650651 waitDuration := backoffResetWait - timeSinceLastAttempt
651- log .Debugf ( "Waiting %v before attempting to transfer proof "+
652- "(locator_hash=%x) using backoff procedure" ,
653- waitDuration , locatorHash [:] )
652+ log .DebugS ( ctx , "Backoff: waiting before attempting to "+
653+ "transfer proof" , "wait_duration" , waitDuration ,
654+ "locator" , locatorStr )
654655
655656 err := b .wait (ctx , waitDuration )
656657 if err != nil {
@@ -672,13 +673,13 @@ func (b *BackoffHandler) Exec(ctx context.Context, proofLocator Locator,
672673 return fmt .Errorf ("backoff config not specified" )
673674 }
674675
675- locatorHash , err := proofLocator .Hash ()
676+ locatorStr , err := proofLocator .LogString ()
676677 if err != nil {
677- return err
678+ return fmt . Errorf ( "generate locator log string: %w" , err )
678679 }
679- log . Infof ( "Starting proof transfer backoff procedure " +
680- "(transfer_type=%s, locator_hash=%x)" , transferType ,
681- locatorHash [:] )
680+
681+ log . InfoS ( ctx , "Starting proof transfer backoff procedure" ,
682+ "transfer_type" , transferType , "locator" , locatorStr )
682683
683684 // Conditionally perform an initial delay based on the transfer log to
684685 // ensure that we don't spam the courier service with proof transfer
@@ -708,7 +709,7 @@ func (b *BackoffHandler) Exec(ctx context.Context, proofLocator Locator,
708709 "attempt: %w" , err )
709710 }
710711
711- // Execute target proof transfer function.
712+ // Execute the target proof transfer function.
712713 errExec = transferFunc ()
713714 if errExec == nil {
714715 // The target function executed successfully, we can
@@ -732,10 +733,10 @@ func (b *BackoffHandler) Exec(ctx context.Context, proofLocator Locator,
732733 )
733734 subscriberEvent (waitEvent )
734735
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 )
736+ log .DebugS ( ctx , " Backing off: proof transfer failed" ,
737+ "transfer_type" , transferType , "locator" ,
738+ locatorStr , "backoff" , backoff , " attempt" , i , "err " ,
739+ errExec )
739740
740741 // Wait before reattempting execution.
741742 err := b .wait (ctx , backoff )
@@ -976,8 +977,10 @@ func (h *HashMailCourier) DeliverProof(ctx context.Context, recipient Recipient,
976977
977978 return nil
978979 }
980+
981+ backoffCtx := btclog .WithCtx (ctx , "addr" , h .addr .String ())
979982 err := h .backoffHandle .Exec (
980- ctx , proof .Locator , SendTransferType , deliveryExec ,
983+ backoffCtx , proof .Locator , SendTransferType , deliveryExec ,
981984 h .publishSubscriberEvent ,
982985 )
983986 if err != nil {
@@ -1550,8 +1553,10 @@ func (c *UniverseRpcCourier) DeliverProof(ctx context.Context,
15501553
15511554 return nil
15521555 }
1556+
1557+ backoffCtx := btclog .WithCtx (ctx , "addr" , c .addr .String ())
15531558 err = c .backoffHandle .Exec (
1554- ctx , loc , SendTransferType , deliverFunc ,
1559+ backoffCtx , loc , SendTransferType , deliverFunc ,
15551560 c .publishSubscriberEvent ,
15561561 )
15571562 if err != nil {
@@ -1626,8 +1631,10 @@ func (c *UniverseRpcCourier) ReceiveProof(ctx context.Context,
16261631
16271632 return nil
16281633 }
1634+
1635+ backoffCtx := btclog .WithCtx (ctx , "addr" , c .addr .String ())
16291636 err := c .backoffHandle .Exec (
1630- ctx , loc , ReceiveTransferType , receiveFunc ,
1637+ backoffCtx , loc , ReceiveTransferType , receiveFunc ,
16311638 c .publishSubscriberEvent ,
16321639 )
16331640 if err != nil {
0 commit comments