lnwallet: replace spew.Sdump with lnutils.SpewLogClosure for lazy evaluation
In this commit, we replace all instances of spew.Sdump in the lnwallet package and its subpackages with lnutils.SpewLogClosure. This change ensures that expensive debug dump operations are only performed when the log level actually requires them.
This commit is contained in:
5 files changed
+15
-15
No files matched your search
@@ -24,12 +24,12 @@ import (
|
||||
"github.com/btcsuite/btcwallet/wallet/txrules"
|
||||
"github.com/btcsuite/btcwallet/walletdb"
|
||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/blockcache"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
@@ -1184,7 +1184,8 @@ func (b *BtcWallet) PublishTransaction(tx *wire.MsgTx, label string) error {
|
||||
}
|
||||
|
||||
result := results[0]
|
||||
log.Debugf("TestMempoolAccept result: %s", spew.Sdump(result))
|
||||
log.Debugf("TestMempoolAccept result: %s",
|
||||
lnutils.SpewLogClosure(result))
|
||||
|
||||
// Once mempool check passed, we can publish the transaction.
|
||||
if result.Allowed {
|
||||
@@ -1833,7 +1834,8 @@ func (b *BtcWallet) CheckMempoolAcceptance(tx *wire.MsgTx) error {
|
||||
}
|
||||
|
||||
result := results[0]
|
||||
log.Debugf("TestMempoolAccept result: %s", spew.Sdump(result))
|
||||
log.Debugf("TestMempoolAccept result: %s",
|
||||
lnutils.SpewLogClosure(result))
|
||||
|
||||
// Mempool check failed, we now map the reject reason to a proper RPC
|
||||
// error and return it.
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
@@ -414,7 +413,7 @@ func (c *ChanCloser) initChanShutdown() (*lnwire.Shutdown, error) {
|
||||
)
|
||||
|
||||
chancloserLog.Infof("Initiating shutdown w/ nonce: %v",
|
||||
spew.Sdump(firstClosingNonce.PubNonce))
|
||||
lnutils.SpewLogClosure(firstClosingNonce.PubNonce))
|
||||
}
|
||||
|
||||
// Before closing, we'll attempt to send a disable update for the
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/mempool"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/labels"
|
||||
@@ -799,7 +798,7 @@ func (l *LocalCloseStart) ProcessEvent(event ProtocolEvent,
|
||||
l.RemoteDeliveryScript[:], absoluteFee)
|
||||
|
||||
chancloserLog.Infof("proposing closing_tx=%v",
|
||||
spew.Sdump(closeTx))
|
||||
lnutils.SpewLogClosure(closeTx))
|
||||
|
||||
// Now that we have our signature, we'll set the proper
|
||||
// closingSigs field based on if the remote party's output is
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog/v2"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
@@ -2850,7 +2849,7 @@ func (lc *LightningChannel) fetchCommitmentView(
|
||||
return nil, fmt.Errorf("height=%v, for ChannelPoint(%v) "+
|
||||
"attempts to create commitment with feerate %v: %v",
|
||||
nextHeight, lc.channelState.FundingOutpoint,
|
||||
effFeeRate, spew.Sdump(commitTx))
|
||||
effFeeRate, lnutils.SpewLogClosure(commitTx))
|
||||
}
|
||||
|
||||
// Given the custom blob of the past state, and this new HTLC view,
|
||||
|
||||
+7
-6
@@ -21,12 +21,12 @@ import (
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcwallet/wallet"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/fn/v2"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanvalidate"
|
||||
@@ -1733,7 +1733,8 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
|
||||
}
|
||||
|
||||
walletLog.Tracef("Funding tx for ChannelPoint(%v) "+
|
||||
"generated: %v", chanPoint, spew.Sdump(fundingTx))
|
||||
"generated: %v", chanPoint,
|
||||
lnutils.SpewLogClosure(fundingTx))
|
||||
}
|
||||
|
||||
// If we landed here and didn't exit early, it means we already have
|
||||
@@ -2001,9 +2002,9 @@ func (l *LightningWallet) handleChanPointReady(req *continueContributionMsg) {
|
||||
txsort.InPlaceSort(theirCommitTx)
|
||||
|
||||
walletLog.Tracef("Local commit tx for ChannelPoint(%v): %v",
|
||||
chanPoint, spew.Sdump(ourCommitTx))
|
||||
chanPoint, lnutils.SpewLogClosure(ourCommitTx))
|
||||
walletLog.Tracef("Remote commit tx for ChannelPoint(%v): %v",
|
||||
chanPoint, spew.Sdump(theirCommitTx))
|
||||
chanPoint, lnutils.SpewLogClosure(theirCommitTx))
|
||||
|
||||
// Record newly available information within the open channel state.
|
||||
chanState.FundingOutpoint = chanPoint
|
||||
@@ -2449,9 +2450,9 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
|
||||
chanState.RemoteCommitment.CommitTx = theirCommitTx
|
||||
|
||||
walletLog.Debugf("Local commit tx for ChannelPoint(%v): %v",
|
||||
req.fundingOutpoint, spew.Sdump(ourCommitTx))
|
||||
req.fundingOutpoint, lnutils.SpewLogClosure(ourCommitTx))
|
||||
walletLog.Debugf("Remote commit tx for ChannelPoint(%v): %v",
|
||||
req.fundingOutpoint, spew.Sdump(theirCommitTx))
|
||||
req.fundingOutpoint, lnutils.SpewLogClosure(theirCommitTx))
|
||||
|
||||
// With both commitment transactions created, we'll now verify their
|
||||
// signature on our commitment.
|
||||
|
||||
Reference in new issue
Block a user