Skip to content

Commit f77cd51

Browse files
committed
autopilot+funding+rpc+invoices: complete migration to lazy debug logging
In this commit, we complete the migration to lnutils.SpewLogClosure for the remaining application-layer components. This includes the autopilot channel management system, the funding manager, the RPC server, and the invoice storage subsystem.
1 parent 2cc4079 commit f77cd51

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

autopilot/agent.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111

1212
"github.com/btcsuite/btcd/btcec/v2"
1313
"github.com/btcsuite/btcd/btcutil"
14-
"github.com/davecgh/go-spew/spew"
1514
"github.com/lightningnetwork/lnd/fn/v2"
15+
"github.com/lightningnetwork/lnd/lnutils"
1616
"github.com/lightningnetwork/lnd/lnwire"
1717
)
1818

@@ -443,7 +443,7 @@ func (a *Agent) controller(ctx context.Context) {
443443
case *chanOpenUpdate:
444444
log.Debugf("New channel successfully opened, "+
445445
"updating state with: %v",
446-
spew.Sdump(update.newChan))
446+
lnutils.SpewLogClosure(update.newChan))
447447

448448
newChan := update.newChan
449449
a.chanStateMtx.Lock()
@@ -460,7 +460,9 @@ func (a *Agent) controller(ctx context.Context) {
460460
case *chanCloseUpdate:
461461
log.Debugf("Applying closed channel "+
462462
"updates: %v",
463-
spew.Sdump(update.closedChans))
463+
lnutils.SpewLogClosure(
464+
update.closedChans),
465+
)
464466

465467
a.chanStateMtx.Lock()
466468
for _, closedChan := range update.closedChans {
@@ -515,7 +517,8 @@ func (a *Agent) controller(ctx context.Context) {
515517
}
516518

517519
a.pendingMtx.Lock()
518-
log.Debugf("Pending channels: %v", spew.Sdump(a.pendingOpens))
520+
log.Debugf("Pending channels: %v",
521+
lnutils.SpewLogClosure(a.pendingOpens))
519522
a.pendingMtx.Unlock()
520523

521524
// With all the updates applied, we'll obtain a set of the
@@ -699,7 +702,7 @@ func (a *Agent) openChans(ctx context.Context, availableFunds btcutil.Amount,
699702
}
700703

701704
log.Infof("Attempting to execute channel attachment "+
702-
"directives: %v", spew.Sdump(chanCandidates))
705+
"directives: %v", lnutils.SpewLogClosure(chanCandidates))
703706

704707
// Before proceeding, check to see if we have any slots
705708
// available to open channels. If there are any, we will attempt

funding/manager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/btcsuite/btcd/chaincfg/chainhash"
1919
"github.com/btcsuite/btcd/txscript"
2020
"github.com/btcsuite/btcd/wire"
21-
"github.com/davecgh/go-spew/spew"
2221
"github.com/lightningnetwork/lnd/chainntnfs"
2322
"github.com/lightningnetwork/lnd/chanacceptor"
2423
"github.com/lightningnetwork/lnd/channeldb"
@@ -992,7 +991,9 @@ func (f *Manager) failFundingFlow(peer lnpeer.Peer, cid *chanIdentifier,
992991
}
993992

994993
log.Debugf("Sending funding error to peer (%x): %v",
995-
peer.IdentityKey().SerializeCompressed(), spew.Sdump(errMsg))
994+
peer.IdentityKey().SerializeCompressed(),
995+
lnutils.SpewLogClosure(errMsg))
996+
996997
if err := peer.SendMessage(false, errMsg); err != nil {
997998
log.Errorf("unable to send error message to peer %v", err)
998999
}
@@ -1012,7 +1013,7 @@ func (f *Manager) sendWarning(peer lnpeer.Peer, cid *chanIdentifier,
10121013

10131014
log.Debugf("Sending funding warning to peer (%x): %v",
10141015
peer.IdentityKey().SerializeCompressed(),
1015-
spew.Sdump(errMsg),
1016+
lnutils.SpewLogClosure(errMsg),
10161017
)
10171018

10181019
if err := peer.SendMessage(false, errMsg); err != nil {

invoices/sql_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
"strconv"
1111
"time"
1212

13-
"github.com/davecgh/go-spew/spew"
1413
"github.com/lightningnetwork/lnd/clock"
1514
"github.com/lightningnetwork/lnd/graph/db/models"
1615
"github.com/lightningnetwork/lnd/lntypes"
16+
"github.com/lightningnetwork/lnd/lnutils"
1717
"github.com/lightningnetwork/lnd/lnwire"
1818
"github.com/lightningnetwork/lnd/record"
1919
"github.com/lightningnetwork/lnd/sqldb"
@@ -409,7 +409,7 @@ func getInvoiceByRef(ctx context.Context,
409409
// In case the reference is ambiguous, meaning it matches more
410410
// than one invoice, we'll return an error.
411411
return sqlc.Invoice{}, fmt.Errorf("ambiguous invoice ref: "+
412-
"%s: %s", ref.String(), spew.Sdump(rows))
412+
"%s: %s", ref.String(), lnutils.SpewLogClosure(rows))
413413

414414
case err != nil:
415415
return sqlc.Invoice{}, fmt.Errorf("unable to fetch invoice: %w",

rpcserver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"github.com/btcsuite/btcwallet/waddrmgr"
3434
"github.com/btcsuite/btcwallet/wallet"
3535
"github.com/btcsuite/btcwallet/wallet/txauthor"
36-
"github.com/davecgh/go-spew/spew"
3736
proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
3837
"github.com/lightningnetwork/lnd/autopilot"
3938
"github.com/lightningnetwork/lnd/build"
@@ -1526,7 +1525,8 @@ func (r *rpcServer) SendCoins(ctx context.Context,
15261525
}
15271526

15281527
rpcsLog.Debugf("Sweeping coins from wallet to addr=%v, "+
1529-
"with tx=%v", in.Addr, spew.Sdump(sweepTxPkg.SweepTx))
1528+
"with tx=%v", in.Addr,
1529+
lnutils.SpewLogClosure(sweepTxPkg.SweepTx))
15301530

15311531
// As our sweep transaction was created, successfully, we'll
15321532
// now attempt to publish it, cancelling the sweep pkg to
@@ -1612,7 +1612,7 @@ func (r *rpcServer) SendMany(ctx context.Context,
16121612
}
16131613

16141614
rpcsLog.Infof("[sendmany] outputs=%v, sat/kw=%v",
1615-
spew.Sdump(in.AddrToAmount), int64(feePerKw))
1615+
lnutils.SpewLogClosure(in.AddrToAmount), int64(feePerKw))
16161616

16171617
var txid *chainhash.Hash
16181618

0 commit comments

Comments
 (0)