multi: add SpewLogClosure to avoid code repetition

This commit is contained in:
yyforyongyu committed 2024-07-25 22:18:49 +08:00
1 parent b6049ff94b
commit d992cf94d6
19 files changed
+57 -144

No files matched your search

+2 -4
View File
@@ -4,7 +4,6 @@ import (
"net" "net"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/keychain" "github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"
@@ -64,9 +63,8 @@ func Recover(backups []Single, restorer ChannelRestorer,
log.Infof("Attempting to connect to node=%x (addrs=%v) to "+ log.Infof("Attempting to connect to node=%x (addrs=%v) to "+
"restore ChannelPoint(%v)", "restore ChannelPoint(%v)",
backup.RemoteNodePub.SerializeCompressed(), backup.RemoteNodePub.SerializeCompressed(),
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(backups[i].Addresses),
return spew.Sdump(backups[i].Addresses) backup.FundingOutpoint)
}), backup.FundingOutpoint)
err = peerConnector.ConnectPeer( err = peerConnector.ConnectPeer(
backup.RemoteNodePub, backup.Addresses, backup.RemoteNodePub, backup.Addresses,
+5 -14
View File
@@ -13,7 +13,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
@@ -733,10 +732,8 @@ justiceTxBroadcast:
} }
finalTx := justiceTxs.spendAll finalTx := justiceTxs.spendAll
brarLog.Debugf("Broadcasting justice tx: %v", lnutils.NewLogClosure( brarLog.Debugf("Broadcasting justice tx: %v", lnutils.SpewLogClosure(
func() string { finalTx))
return spew.Sdump(finalTx)
}))
// We'll now attempt to broadcast the transaction which finalized the // We'll now attempt to broadcast the transaction which finalized the
// channel's retribution against the cheating counter party. // channel's retribution against the cheating counter party.
@@ -859,9 +856,7 @@ Loop:
brarLog.Debugf("Broadcasting justice tx "+ brarLog.Debugf("Broadcasting justice tx "+
"spending commitment outs: %v", "spending commitment outs: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(tx))
return spew.Sdump(tx)
}))
err = b.cfg.PublishTransaction(tx, label) err = b.cfg.PublishTransaction(tx, label)
if err != nil { if err != nil {
@@ -876,9 +871,7 @@ Loop:
brarLog.Debugf("Broadcasting justice tx "+ brarLog.Debugf("Broadcasting justice tx "+
"spending HTLC outs: %v", "spending HTLC outs: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(tx))
return spew.Sdump(tx)
}))
err = b.cfg.PublishTransaction(tx, label) err = b.cfg.PublishTransaction(tx, label)
if err != nil { if err != nil {
@@ -893,9 +886,7 @@ Loop:
brarLog.Debugf("Broadcasting justice tx "+ brarLog.Debugf("Broadcasting justice tx "+
"spending second-level HTLC output: %v", "spending second-level HTLC output: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(tx))
return spew.Sdump(tx)
}))
err = b.cfg.PublishTransaction(tx, label) err = b.cfg.PublishTransaction(tx, label)
if err != nil { if err != nil {
+6 -21
View File
@@ -14,7 +14,6 @@ import (
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models" "github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn"
@@ -466,10 +465,8 @@ func (c *ChannelArbitrator) Start(state *chanArbStartState) error {
} }
log.Debugf("Starting ChannelArbitrator(%v), htlc_set=%v, state=%v", log.Debugf("Starting ChannelArbitrator(%v), htlc_set=%v, state=%v",
c.cfg.ChanPoint, lnutils.NewLogClosure(func() string { c.cfg.ChanPoint, lnutils.SpewLogClosure(c.activeHTLCs),
return spew.Sdump(c.activeHTLCs) state.currentState)
}), state.currentState,
)
// Set our state from our starting state. // Set our state from our starting state.
c.state = state.currentState c.state = state.currentState
@@ -959,10 +956,7 @@ func (c *ChannelArbitrator) stateStep(
// Otherwise, we'll log that we checked the HTLC actions as the // Otherwise, we'll log that we checked the HTLC actions as the
// commitment transaction has already been broadcast. // commitment transaction has already been broadcast.
log.Tracef("ChannelArbitrator(%v): logging chain_actions=%v", log.Tracef("ChannelArbitrator(%v): logging chain_actions=%v",
c.cfg.ChanPoint, c.cfg.ChanPoint, lnutils.SpewLogClosure(chainActions))
lnutils.NewLogClosure(func() string {
return spew.Sdump(chainActions)
}))
// Depending on the type of trigger, we'll either "tunnel" // Depending on the type of trigger, we'll either "tunnel"
// through to a farther state, or just proceed linearly to the // through to a farther state, or just proceed linearly to the
@@ -1097,10 +1091,7 @@ func (c *ChannelArbitrator) stateStep(
// channel resolution state. // channel resolution state.
log.Infof("Broadcasting force close transaction %v, "+ log.Infof("Broadcasting force close transaction %v, "+
"ChannelPoint(%v): %v", closeTx.TxHash(), "ChannelPoint(%v): %v", closeTx.TxHash(),
c.cfg.ChanPoint, c.cfg.ChanPoint, lnutils.SpewLogClosure(closeTx))
lnutils.NewLogClosure(func() string {
return spew.Sdump(closeTx)
}))
// At this point, we'll now broadcast the commitment // At this point, we'll now broadcast the commitment
// transaction itself. // transaction itself.
@@ -1225,9 +1216,7 @@ func (c *ChannelArbitrator) stateStep(
if len(pktsToSend) != 0 { if len(pktsToSend) != 0 {
log.Debugf("ChannelArbitrator(%v): sending "+ log.Debugf("ChannelArbitrator(%v): sending "+
"resolution message=%v", c.cfg.ChanPoint, "resolution message=%v", c.cfg.ChanPoint,
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(pktsToSend))
return spew.Sdump(pktsToSend)
}))
err := c.cfg.DeliverResolutionMsg(pktsToSend...) err := c.cfg.DeliverResolutionMsg(pktsToSend...)
if err != nil { if err != nil {
@@ -2742,11 +2731,7 @@ func (c *ChannelArbitrator) notifyContractUpdate(upd *ContractUpdate) {
c.unmergedSet[upd.HtlcKey] = newHtlcSet(upd.Htlcs) c.unmergedSet[upd.HtlcKey] = newHtlcSet(upd.Htlcs)
log.Tracef("ChannelArbitrator(%v): fresh set of htlcs=%v", log.Tracef("ChannelArbitrator(%v): fresh set of htlcs=%v",
c.cfg.ChanPoint, c.cfg.ChanPoint, lnutils.SpewLogClosure(upd))
lnutils.NewLogClosure(func() string {
return spew.Sdump(upd)
}),
)
} }
// updateActiveHTLCs merges the unmerged set of HTLCs from the link with // updateActiveHTLCs merges the unmerged set of HTLCs from the link with
+1 -4
View File
@@ -948,10 +948,7 @@ func (u *UtxoNursery) waitForSweepConf(classHeight uint32,
func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) error { func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) error {
utxnLog.Infof("Publishing CLTV-delayed HTLC output using timeout tx "+ utxnLog.Infof("Publishing CLTV-delayed HTLC output using timeout tx "+
"(txid=%v): %v", baby.timeoutTx.TxHash(), "(txid=%v): %v", baby.timeoutTx.TxHash(),
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(baby.timeoutTx))
return spew.Sdump(baby.timeoutTx)
}),
)
// We'll now broadcast the HTLC transaction, then wait for it to be // We'll now broadcast the HTLC transaction, then wait for it to be
// confirmed before transitioning it to kindergarten. // confirmed before transitioning it to kindergarten.
+1 -5
View File
@@ -14,7 +14,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil/bech32" "github.com/btcsuite/btcd/btcutil/bech32"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/autopilot" "github.com/lightningnetwork/lnd/autopilot"
"github.com/lightningnetwork/lnd/lnutils" "github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
@@ -432,10 +431,7 @@ search:
} }
log.Tracef("Retrieved SRV records from dns seed: %v", log.Tracef("Retrieved SRV records from dns seed: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(addrs))
return spew.Sdump(addrs)
}),
)
// Next, we'll need to issue an A record request for each of // Next, we'll need to issue an A record request for each of
// the nodes, skipping it if nothing comes back. // the nodes, skipping it if nothing comes back.
+1 -4
View File
@@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/batch" "github.com/lightningnetwork/lnd/batch"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
@@ -1432,9 +1431,7 @@ func (b *Builder) processUpdate(msg interface{},
} }
log.Tracef("New channel update applied: %v", log.Tracef("New channel update applied: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(msg))
return spew.Sdump(msg)
}))
b.stats.incNumChannelUpdates() b.stats.incNumChannelUpdates()
default: default:
+6 -13
View File
@@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch/hop" "github.com/lightningnetwork/lnd/htlcswitch/hop"
@@ -801,10 +800,8 @@ func (cm *circuitMap) CommitCircuits(circuits ...*PaymentCircuit) (
inKeys = append(inKeys, circuit.Incoming) inKeys = append(inKeys, circuit.Incoming)
} }
log.Tracef("Committing fresh circuits: %v", lnutils.NewLogClosure( log.Tracef("Committing fresh circuits: %v", lnutils.SpewLogClosure(
func() string { inKeys))
return spew.Sdump(inKeys)
}))
actions := &CircuitFwdActions{} actions := &CircuitFwdActions{}
@@ -950,10 +947,8 @@ func (cm *circuitMap) OpenCircuits(keystones ...Keystone) error {
return nil return nil
} }
log.Tracef("Opening finalized circuits: %v", lnutils.NewLogClosure( log.Tracef("Opening finalized circuits: %v", lnutils.SpewLogClosure(
func() string { keystones))
return spew.Sdump(keystones)
}))
// Check that all keystones correspond to committed-but-unopened // Check that all keystones correspond to committed-but-unopened
// circuits. // circuits.
@@ -1081,10 +1076,8 @@ func (cm *circuitMap) CloseCircuit(outKey CircuitKey) (*PaymentCircuit, error) {
// circuit was already cleaned up at a different point in time. // circuit was already cleaned up at a different point in time.
func (cm *circuitMap) DeleteCircuits(inKeys ...CircuitKey) error { func (cm *circuitMap) DeleteCircuits(inKeys ...CircuitKey) error {
log.Tracef("Deleting resolved circuits: %v", lnutils.NewLogClosure( log.Tracef("Deleting resolved circuits: %v", lnutils.SpewLogClosure(
func() string { inKeys))
return spew.Sdump(inKeys)
}))
var ( var (
closingCircuits = make(map[CircuitKey]struct{}) closingCircuits = make(map[CircuitKey]struct{})
+3 -8
View File
@@ -13,7 +13,6 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog" "github.com/btcsuite/btclog"
"github.com/davecgh/go-spew/spew"
"github.com/go-errors/errors" "github.com/go-errors/errors"
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
@@ -2537,13 +2536,9 @@ func (l *channelLink) updateCommitTx() error {
l.log.Tracef("revocation window exhausted, unable to send: "+ l.log.Tracef("revocation window exhausted, unable to send: "+
"%v, pend_updates=%v, dangling_closes%v", "%v, pend_updates=%v, dangling_closes%v",
l.channel.PendingLocalUpdateCount(), l.channel.PendingLocalUpdateCount(),
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(l.openedCircuits),
return spew.Sdump(l.openedCircuits) lnutils.SpewLogClosure(l.closedCircuits))
}),
lnutils.NewLogClosure(func() string {
return spew.Sdump(l.closedCircuits)
}),
)
return nil return nil
} else if err != nil { } else if err != nil {
return err return err
+4 -10
View File
@@ -614,10 +614,8 @@ func (s *Switch) SendHTLC(firstHop lnwire.ShortChannelID, attemptID uint64,
func (s *Switch) UpdateForwardingPolicies( func (s *Switch) UpdateForwardingPolicies(
chanPolicies map[wire.OutPoint]models.ForwardingPolicy) { chanPolicies map[wire.OutPoint]models.ForwardingPolicy) {
log.Tracef("Updating link policies: %v", lnutils.NewLogClosure( log.Tracef("Updating link policies: %v", lnutils.SpewLogClosure(
func() string { chanPolicies))
return spew.Sdump(chanPolicies)
}))
s.indexMtx.RLock() s.indexMtx.RLock()
@@ -1216,9 +1214,7 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
log.Warnf("unable to find err source for "+ log.Warnf("unable to find err source for "+
"outgoing_link=%v, errors=%v", "outgoing_link=%v, errors=%v",
packet.outgoingChanID, packet.outgoingChanID,
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(linkErrs))
return spew.Sdump(linkErrs)
}))
} }
log.Tracef("incoming HTLC(%x) violated "+ log.Tracef("incoming HTLC(%x) violated "+
@@ -1999,9 +1995,7 @@ out:
log.Tracef("Acked %d settle fails: %v", log.Tracef("Acked %d settle fails: %v",
len(s.pendingSettleFails), len(s.pendingSettleFails),
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(s.pendingSettleFails))
return spew.Sdump(s.pendingSettleFails)
}))
// Reset the pendingSettleFails buffer while keeping acquired // Reset the pendingSettleFails buffer while keeping acquired
// memory. // memory.
+1 -5
View File
@@ -15,7 +15,6 @@ import (
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models" "github.com/lightningnetwork/lnd/channeldb/models"
"github.com/lightningnetwork/lnd/invoices" "github.com/lightningnetwork/lnd/invoices"
@@ -474,10 +473,7 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
} }
log.Tracef("[addinvoice] adding new invoice %v", log.Tracef("[addinvoice] adding new invoice %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(newInvoice))
return spew.Sdump(newInvoice)
}),
)
// With all sanity checks passed, write the invoice to the database. // With all sanity checks passed, write the invoice to the database.
_, err = cfg.AddInvoice(ctx, newInvoice, paymentHash) _, err = cfg.AddInvoice(ctx, newInvoice, paymentHash)
+10
View File
@@ -1,5 +1,7 @@
package lnutils package lnutils
import "github.com/davecgh/go-spew/spew"
// LogClosure is used to provide a closure over expensive logging operations so // LogClosure is used to provide a closure over expensive logging operations so
// don't have to be performed when the logging level doesn't warrant it. // don't have to be performed when the logging level doesn't warrant it.
type LogClosure func() string type LogClosure func() string
@@ -15,3 +17,11 @@ func (c LogClosure) String() string {
func NewLogClosure(c func() string) LogClosure { func NewLogClosure(c func() string) LogClosure {
return LogClosure(c) return LogClosure(c)
} }
// SpewLogClosure takes an interface and returns the string of it created from
// `spew.Sdump` in a LogClosure.
func SpewLogClosure(a any) LogClosure {
return func() string {
return spew.Sdump(a)
}
}
+1 -4
View File
@@ -870,10 +870,7 @@ func (c *ChanCloser) ReceiveClosingSigned( //nolint:funlen
// With the closing transaction crafted, we'll now broadcast it // With the closing transaction crafted, we'll now broadcast it
// to the network. // to the network.
chancloserLog.Infof("Broadcasting cooperative close tx: %v", chancloserLog.Infof("Broadcasting cooperative close tx: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(closeTx))
return spew.Sdump(closeTx)
}),
)
// Create a close channel label. // Create a close channel label.
chanID := c.cfg.Channel.ShortChanID() chanID := c.cfg.Channel.ShortChanID()
+7 -26
View File
@@ -1870,10 +1870,7 @@ func (lc *LightningChannel) restoreCommitState(
lc.localCommitChain.addCommitment(localCommit) lc.localCommitChain.addCommitment(localCommit)
lc.log.Tracef("starting local commitment: %v", lc.log.Tracef("starting local commitment: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(lc.localCommitChain.tail()))
return spew.Sdump(lc.localCommitChain.tail())
}),
)
// We'll also do the same for the remote commitment chain. // We'll also do the same for the remote commitment chain.
remoteCommit, err := lc.diskCommitToMemCommit( remoteCommit, err := lc.diskCommitToMemCommit(
@@ -1886,10 +1883,7 @@ func (lc *LightningChannel) restoreCommitState(
lc.remoteCommitChain.addCommitment(remoteCommit) lc.remoteCommitChain.addCommitment(remoteCommit)
lc.log.Tracef("starting remote commitment: %v", lc.log.Tracef("starting remote commitment: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(lc.remoteCommitChain.tail()))
return spew.Sdump(lc.remoteCommitChain.tail())
}),
)
var ( var (
pendingRemoteCommit *commitment pendingRemoteCommit *commitment
@@ -1921,10 +1915,7 @@ func (lc *LightningChannel) restoreCommitState(
lc.remoteCommitChain.addCommitment(pendingRemoteCommit) lc.remoteCommitChain.addCommitment(pendingRemoteCommit)
lc.log.Debugf("pending remote commitment: %v", lc.log.Debugf("pending remote commitment: %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(lc.remoteCommitChain.tip()))
return spew.Sdump(lc.remoteCommitChain.tip())
}),
)
// We'll also re-create the set of commitment keys needed to // We'll also re-create the set of commitment keys needed to
// fully re-derive the state. // fully re-derive the state.
@@ -3246,12 +3237,8 @@ func (lc *LightningChannel) fetchParent(entry *PaymentDescriptor,
return nil, fmt.Errorf("unable to find parent entry "+ return nil, fmt.Errorf("unable to find parent entry "+
"%d in %v update log: %v\nUpdatelog: %v", "%d in %v update log: %v\nUpdatelog: %v",
entry.ParentIndex, logName, entry.ParentIndex, logName,
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(entry),
return spew.Sdump(entry) lnutils.SpewLogClosure(updateLog))
}), lnutils.NewLogClosure(func() string {
return spew.Sdump(updateLog)
}),
)
// The parent add height should never be zero at this point. If // The parent add height should never be zero at this point. If
// that's the case we probably forgot to send a new commitment. // that's the case we probably forgot to send a new commitment.
@@ -4250,10 +4237,7 @@ func (lc *LightningChannel) SignNextCommitment() (*NewCommitState, error) {
"their_balance=%v, commit_tx: %v", "their_balance=%v, commit_tx: %v",
newCommitView.ourBalance, newCommitView.ourBalance,
newCommitView.theirBalance, newCommitView.theirBalance,
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(newCommitView.txn))
return spew.Sdump(newCommitView.txn)
}),
)
// With the commitment view constructed, if there are any HTLC's, we'll // With the commitment view constructed, if there are any HTLC's, we'll
// need to generate signatures of each of them for the remote party's // need to generate signatures of each of them for the remote party's
@@ -5210,10 +5194,7 @@ func (lc *LightningChannel) ReceiveNewCommitment(commitSigs *CommitSigs) error {
lc.log.Tracef("local chain: our_balance=%v, "+ lc.log.Tracef("local chain: our_balance=%v, "+
"their_balance=%v, commit_tx: %v", "their_balance=%v, commit_tx: %v",
localCommitmentView.ourBalance, localCommitmentView.theirBalance, localCommitmentView.ourBalance, localCommitmentView.theirBalance,
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(localCommitmentView.txn))
return spew.Sdump(localCommitmentView.txn)
}),
)
// As an optimization, we'll generate a series of jobs for the worker // As an optimization, we'll generate a series of jobs for the worker
// pool to verify each of the HTLC signatures presented. Once // pool to verify each of the HTLC signatures presented. Once
+1 -3
View File
@@ -2184,9 +2184,7 @@ func (p *Brontide) logWireMessage(msg lnwire.Message, read bool) {
prefix = "writeMessage to peer" prefix = "writeMessage to peer"
} }
p.log.Tracef(prefix+": %v", lnutils.NewLogClosure(func() string { p.log.Tracef(prefix+": %v", lnutils.SpewLogClosure(msg))
return spew.Sdump(msg)
}))
} }
// writeMessage writes and flushes the target lnwire.Message to the remote peer. // writeMessage writes and flushes the target lnwire.Message to the remote peer.
+1 -2
View File
@@ -5,7 +5,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btclog" "github.com/btcsuite/btclog"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/build" "github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models" "github.com/lightningnetwork/lnd/channeldb/models"
@@ -433,7 +432,7 @@ func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
policy.FeeProportionalMillionths = lnwire.MilliSatoshi(msg.FeeRate) policy.FeeProportionalMillionths = lnwire.MilliSatoshi(msg.FeeRate)
log.Debugf("New private channel update applied: %v", log.Debugf("New private channel update applied: %v",
lnutils.NewLogClosure(func() string { return spew.Sdump(msg) })) lnutils.SpewLogClosure(msg))
return true return true
} }
+3 -9
View File
@@ -670,10 +670,7 @@ func (r *ChannelRouter) FindRoute(req *RouteRequest) (*route.Route, float64,
} }
go log.Tracef("Obtained path to send %v to %x: %v", go log.Tracef("Obtained path to send %v to %x: %v",
req.Amount, req.Target, lnutils.NewLogClosure(func() string { req.Amount, req.Target, lnutils.SpewLogClosure(route))
return spew.Sdump(route)
}),
)
return route, probability, nil return route, probability, nil
} }
@@ -1091,11 +1088,8 @@ func (r *ChannelRouter) sendToRoute(htlcHash lntypes.Hash, rt *route.Route,
return nil, err return nil, err
} }
log.Tracef("Dispatching SendToRoute for HTLC hash %v: %v", log.Tracef("Dispatching SendToRoute for HTLC hash %v: %v", htlcHash,
htlcHash, lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(rt))
return spew.Sdump(rt)
}),
)
// Since the HTLC hashes and preimages are specified manually over the // Since the HTLC hashes and preimages are specified manually over the
// RPC for SendToRoute requests, we don't have to worry about creating // RPC for SendToRoute requests, we don't have to worry about creating
+1 -3
View File
@@ -5846,9 +5846,7 @@ func (r *rpcServer) LookupInvoice(ctx context.Context,
} }
rpcsLog.Tracef("[lookupinvoice] located invoice %v", rpcsLog.Tracef("[lookupinvoice] located invoice %v",
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(invoice))
return spew.Sdump(invoice)
}))
rpcInvoice, err := invoicesrpc.CreateRPCInvoice( rpcInvoice, err := invoicesrpc.CreateRPCInvoice(
&invoice, r.cfg.ActiveNetParams.Params, &invoice, r.cfg.ActiveNetParams.Params,
+2 -5
View File
@@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcwallet/chain" "github.com/btcsuite/btcwallet/chain"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/chainntnfs" "github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/fn" "github.com/lightningnetwork/lnd/fn"
"github.com/lightningnetwork/lnd/input" "github.com/lightningnetwork/lnd/input"
@@ -313,10 +312,8 @@ func (t *TxPublisher) isNeutrinoBackend() bool {
// //
// NOTE: part of the Bumper interface. // NOTE: part of the Bumper interface.
func (t *TxPublisher) Broadcast(req *BumpRequest) (<-chan *BumpResult, error) { func (t *TxPublisher) Broadcast(req *BumpRequest) (<-chan *BumpResult, error) {
log.Tracef("Received broadcast request: %s", lnutils.NewLogClosure( log.Tracef("Received broadcast request: %s", lnutils.SpewLogClosure(
func() string { req))
return spew.Sdump(req)
})())
// Attempt an initial broadcast which is guaranteed to comply with the // Attempt an initial broadcast which is guaranteed to comply with the
// RBF rules. // RBF rules.
+1 -4
View File
@@ -1377,10 +1377,7 @@ func (s *UtxoSweeper) handleInputSpent(spend *chainntnfs.SpendDetail) {
log.Debugf("Detected third party spend related to in flight "+ log.Debugf("Detected third party spend related to in flight "+
"inputs (is_ours=%v): %v", isOurTx, "inputs (is_ours=%v): %v", isOurTx,
lnutils.NewLogClosure(func() string { lnutils.SpewLogClosure(spend.SpendingTx))
return spew.Sdump(spend.SpendingTx)
}),
)
} }
// We now use the spending tx to update the state of the inputs. // We now use the spending tx to update the state of the inputs.