Skip to content

Commit 221c3e8

Browse files
authored
Merge pull request #10188 from Roasbeef/logclosure-errwhere
multi: attempt to more uniformly use SpewLogClosure across project
2 parents c02e94e + f77cd51 commit 221c3e8

File tree

20 files changed

+57
-60
lines changed

20 files changed

+57
-60
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

contractcourt/chain_watcher.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,10 @@ func newChainSet(chanState *channeldb.OpenChannel) (*chainSet, error) {
588588

589589
log.Tracef("ChannelPoint(%v): local_commit_type=%v, local_commit=%v",
590590
chanState.FundingOutpoint, chanState.ChanType,
591-
spew.Sdump(localCommit))
591+
lnutils.SpewLogClosure(localCommit))
592592
log.Tracef("ChannelPoint(%v): remote_commit_type=%v, remote_commit=%v",
593593
chanState.FundingOutpoint, chanState.ChanType,
594-
spew.Sdump(remoteCommit))
594+
lnutils.SpewLogClosure(remoteCommit))
595595

596596
// Fetch the current known commit height for the remote party, and
597597
// their pending commitment chain tip if it exists.
@@ -619,7 +619,7 @@ func newChainSet(chanState *channeldb.OpenChannel) (*chainSet, error) {
619619
log.Tracef("ChannelPoint(%v): remote_pending_commit_type=%v, "+
620620
"remote_pending_commit=%v", chanState.FundingOutpoint,
621621
chanState.ChanType,
622-
spew.Sdump(remoteChainTip.Commitment))
622+
lnutils.SpewLogClosure(remoteChainTip.Commitment))
623623

624624
htlcs := remoteChainTip.Commitment.Htlcs
625625
commitSet.HtlcSets[RemotePendingHtlcSet] = htlcs
@@ -995,7 +995,8 @@ func (c *chainWatcher) dispatchCooperativeClose(commitSpend *chainntnfs.SpendDet
995995
broadcastTx := commitSpend.SpendingTx
996996

997997
log.Infof("Cooperative closure for ChannelPoint(%v): %v",
998-
c.cfg.chanState.FundingOutpoint, spew.Sdump(broadcastTx))
998+
c.cfg.chanState.FundingOutpoint,
999+
lnutils.SpewLogClosure(broadcastTx))
9991000

10001001
// If the input *is* final, then we'll check to see which output is
10011002
// ours.

contractcourt/htlc_timeout_resolver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/btcsuite/btcd/chaincfg/chainhash"
1111
"github.com/btcsuite/btcd/txscript"
1212
"github.com/btcsuite/btcd/wire"
13-
"github.com/davecgh/go-spew/spew"
1413
"github.com/lightningnetwork/lnd/chainntnfs"
1514
"github.com/lightningnetwork/lnd/channeldb"
1615
"github.com/lightningnetwork/lnd/fn/v2"
@@ -167,7 +166,7 @@ func (h *htlcTimeoutResolver) claimCleanUp(
167166

168167
log.Infof("%T(%v): extracting preimage! remote party spent "+
169168
"HTLC with tx=%v", h, h.htlcResolution.ClaimOutpoint,
170-
spew.Sdump(commitSpend.SpendingTx))
169+
lnutils.SpewLogClosure(commitSpend.SpendingTx))
171170

172171
// If this is the remote party's commitment, then we'll be looking for
173172
// them to spend using the second-level success transaction.

contractcourt/utxonursery.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/btcsuite/btcd/btcutil"
1313
"github.com/btcsuite/btcd/txscript"
1414
"github.com/btcsuite/btcd/wire"
15-
"github.com/davecgh/go-spew/spew"
1615
"github.com/lightningnetwork/lnd/chainntnfs"
1716
"github.com/lightningnetwork/lnd/channeldb"
1817
"github.com/lightningnetwork/lnd/fn/v2"
@@ -964,7 +963,7 @@ func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro
964963
!errors.Is(err, lnwallet.ErrMempoolFee) {
965964

966965
utxnLog.Errorf("Unable to broadcast baby tx: "+
967-
"%v, %v", err, spew.Sdump(baby.timeoutTx))
966+
"%v, %v", err, lnutils.SpewLogClosure(baby.timeoutTx))
968967
return err
969968
}
970969

discovery/gossiper.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/btcsuite/btcd/btcutil"
1616
"github.com/btcsuite/btcd/chaincfg/chainhash"
1717
"github.com/btcsuite/btcd/wire"
18-
"github.com/davecgh/go-spew/spew"
1918
"github.com/lightninglabs/neutrino/cache"
2019
"github.com/lightninglabs/neutrino/cache/lru"
2120
"github.com/lightningnetwork/lnd/batch"
@@ -1650,7 +1649,7 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(ctx context.Context,
16501649
if err != nil {
16511650
// Something is wrong if SignalDependents returns an error.
16521651
log.Errorf("SignalDependents returned error for msg=%v with "+
1653-
"JobID=%v", spew.Sdump(nMsg.msg), jobID)
1652+
"JobID=%v", lnutils.SpewLogClosure(nMsg.msg), jobID)
16541653

16551654
nMsg.err <- err
16561655

@@ -3196,7 +3195,7 @@ func (d *AuthenticatedGossiper) handleChanUpdate(ctx context.Context,
31963195
if err != nil {
31973196
rErr := fmt.Errorf("unable to validate channel update "+
31983197
"announcement for short_chan_id=%v: %v",
3199-
spew.Sdump(upd.ShortChannelID), err)
3198+
lnutils.SpewLogClosure(upd.ShortChannelID), err)
32003199

32013200
log.Error(rErr)
32023201
nMsg.err <- rErr

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 {

htlcswitch/switch.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
1414
"github.com/btcsuite/btcd/btcutil"
1515
"github.com/btcsuite/btcd/wire"
16-
"github.com/davecgh/go-spew/spew"
1716
"github.com/lightningnetwork/lnd/chainntnfs"
1817
"github.com/lightningnetwork/lnd/channeldb"
1918
"github.com/lightningnetwork/lnd/clock"
@@ -1625,7 +1624,7 @@ out:
16251624
}
16261625

16271626
log.Debugf("Received outside contract resolution, "+
1628-
"mapping to: %v", spew.Sdump(pkt))
1627+
"mapping to: %v", lnutils.SpewLogClosure(pkt))
16291628

16301629
// We don't check the error, as the only failure we can
16311630
// encounter is due to the circuit already being

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",

lnwallet/btcwallet/btcwallet.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import (
2424
"github.com/btcsuite/btcwallet/wallet/txrules"
2525
"github.com/btcsuite/btcwallet/walletdb"
2626
"github.com/btcsuite/btcwallet/wtxmgr"
27-
"github.com/davecgh/go-spew/spew"
2827
"github.com/lightningnetwork/lnd/blockcache"
2928
"github.com/lightningnetwork/lnd/fn/v2"
3029
"github.com/lightningnetwork/lnd/input"
3130
"github.com/lightningnetwork/lnd/keychain"
3231
"github.com/lightningnetwork/lnd/kvdb"
32+
"github.com/lightningnetwork/lnd/lnutils"
3333
"github.com/lightningnetwork/lnd/lnwallet"
3434
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
3535
)
@@ -1184,7 +1184,8 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error {
11841184
}
11851185

11861186
result := results[0]
1187-
log.Debugf("TestMempoolAccept result: %s", spew.Sdump(result))
1187+
log.Debugf("TestMempoolAccept result: %s",
1188+
lnutils.SpewLogClosure(result))
11881189

11891190
// Once mempool check passed, we can publish the transaction.
11901191
if result.Allowed {
@@ -1833,7 +1834,8 @@ func (b *BtcWallet) CheckMempoolAcceptance(tx *wire.MsgTx) error {
18331834
}
18341835

18351836
result := results[0]
1836-
log.Debugf("TestMempoolAccept result: %s", spew.Sdump(result))
1837+
log.Debugf("TestMempoolAccept result: %s",
1838+
lnutils.SpewLogClosure(result))
18371839

18381840
// Mempool check failed, we now map the reject reason to a proper RPC
18391841
// error and return it.

lnwallet/chancloser/chancloser.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/btcsuite/btcd/chaincfg"
1111
"github.com/btcsuite/btcd/txscript"
1212
"github.com/btcsuite/btcd/wire"
13-
"github.com/davecgh/go-spew/spew"
1413
"github.com/lightningnetwork/lnd/channeldb"
1514
"github.com/lightningnetwork/lnd/fn/v2"
1615
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -414,7 +413,7 @@ func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) {
414413
)
415414

416415
chancloserLog.Infof("Initiating shutdown w/ nonce: %v",
417-
spew.Sdump(firstClosingNonce.PubNonce))
416+
lnutils.SpewLogClosure(firstClosingNonce.PubNonce))
418417
}
419418

420419
// Before closing, we'll attempt to send a disable update for the

0 commit comments

Comments
 (0)