mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-21 14:10:35 +02:00
multi: add SpewLogClosure
to avoid code repetition
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
@@ -801,10 +800,8 @@ func (cm *circuitMap) CommitCircuits(circuits ...*PaymentCircuit) (
|
||||
inKeys = append(inKeys, circuit.Incoming)
|
||||
}
|
||||
|
||||
log.Tracef("Committing fresh circuits: %v", lnutils.NewLogClosure(
|
||||
func() string {
|
||||
return spew.Sdump(inKeys)
|
||||
}))
|
||||
log.Tracef("Committing fresh circuits: %v", lnutils.SpewLogClosure(
|
||||
inKeys))
|
||||
|
||||
actions := &CircuitFwdActions{}
|
||||
|
||||
@@ -950,10 +947,8 @@ func (cm *circuitMap) OpenCircuits(keystones ...Keystone) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Tracef("Opening finalized circuits: %v", lnutils.NewLogClosure(
|
||||
func() string {
|
||||
return spew.Sdump(keystones)
|
||||
}))
|
||||
log.Tracef("Opening finalized circuits: %v", lnutils.SpewLogClosure(
|
||||
keystones))
|
||||
|
||||
// Check that all keystones correspond to committed-but-unopened
|
||||
// circuits.
|
||||
@@ -1081,10 +1076,8 @@ func (cm *circuitMap) CloseCircuit(outKey CircuitKey) (*PaymentCircuit, error) {
|
||||
// circuit was already cleaned up at a different point in time.
|
||||
func (cm *circuitMap) DeleteCircuits(inKeys ...CircuitKey) error {
|
||||
|
||||
log.Tracef("Deleting resolved circuits: %v", lnutils.NewLogClosure(
|
||||
func() string {
|
||||
return spew.Sdump(inKeys)
|
||||
}))
|
||||
log.Tracef("Deleting resolved circuits: %v", lnutils.SpewLogClosure(
|
||||
inKeys))
|
||||
|
||||
var (
|
||||
closingCircuits = make(map[CircuitKey]struct{})
|
||||
|
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
@@ -2537,13 +2536,9 @@ func (l *channelLink) updateCommitTx() error {
|
||||
l.log.Tracef("revocation window exhausted, unable to send: "+
|
||||
"%v, pend_updates=%v, dangling_closes%v",
|
||||
l.channel.PendingLocalUpdateCount(),
|
||||
lnutils.NewLogClosure(func() string {
|
||||
return spew.Sdump(l.openedCircuits)
|
||||
}),
|
||||
lnutils.NewLogClosure(func() string {
|
||||
return spew.Sdump(l.closedCircuits)
|
||||
}),
|
||||
)
|
||||
lnutils.SpewLogClosure(l.openedCircuits),
|
||||
lnutils.SpewLogClosure(l.closedCircuits))
|
||||
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
|
@@ -614,10 +614,8 @@ func (s *Switch) SendHTLC(firstHop lnwire.ShortChannelID, attemptID uint64,
|
||||
func (s *Switch) UpdateForwardingPolicies(
|
||||
chanPolicies map[wire.OutPoint]models.ForwardingPolicy) {
|
||||
|
||||
log.Tracef("Updating link policies: %v", lnutils.NewLogClosure(
|
||||
func() string {
|
||||
return spew.Sdump(chanPolicies)
|
||||
}))
|
||||
log.Tracef("Updating link policies: %v", lnutils.SpewLogClosure(
|
||||
chanPolicies))
|
||||
|
||||
s.indexMtx.RLock()
|
||||
|
||||
@@ -1216,9 +1214,7 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
|
||||
log.Warnf("unable to find err source for "+
|
||||
"outgoing_link=%v, errors=%v",
|
||||
packet.outgoingChanID,
|
||||
lnutils.NewLogClosure(func() string {
|
||||
return spew.Sdump(linkErrs)
|
||||
}))
|
||||
lnutils.SpewLogClosure(linkErrs))
|
||||
}
|
||||
|
||||
log.Tracef("incoming HTLC(%x) violated "+
|
||||
@@ -1999,9 +1995,7 @@ out:
|
||||
|
||||
log.Tracef("Acked %d settle fails: %v",
|
||||
len(s.pendingSettleFails),
|
||||
lnutils.NewLogClosure(func() string {
|
||||
return spew.Sdump(s.pendingSettleFails)
|
||||
}))
|
||||
lnutils.SpewLogClosure(s.pendingSettleFails))
|
||||
|
||||
// Reset the pendingSettleFails buffer while keeping acquired
|
||||
// memory.
|
||||
|
Reference in New Issue
Block a user