multi: add NewLogClosure in lnutils to avoid repetition

And replaces all usage of `logClosure` with `lnutils.LogClosure`.
This commit is contained in:
yyforyongyu
2024-07-24 19:31:21 +08:00
parent 7e60d41898
commit b6049ff94b
38 changed files with 103 additions and 299 deletions

View File

@@ -21,6 +21,7 @@ import (
"github.com/lightningnetwork/lnd/htlcswitch/hop"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
@@ -613,9 +614,10 @@ 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", newLogClosure(func() string {
return spew.Sdump(chanPolicies)
}))
log.Tracef("Updating link policies: %v", lnutils.NewLogClosure(
func() string {
return spew.Sdump(chanPolicies)
}))
s.indexMtx.RLock()
@@ -1213,7 +1215,8 @@ func (s *Switch) handlePacketForward(packet *htlcPacket) error {
)
log.Warnf("unable to find err source for "+
"outgoing_link=%v, errors=%v",
packet.outgoingChanID, newLogClosure(func() string {
packet.outgoingChanID,
lnutils.NewLogClosure(func() string {
return spew.Sdump(linkErrs)
}))
}
@@ -1994,8 +1997,9 @@ out:
continue
}
log.Tracef("Acked %d settle fails: %v", len(s.pendingSettleFails),
newLogClosure(func() string {
log.Tracef("Acked %d settle fails: %v",
len(s.pendingSettleFails),
lnutils.NewLogClosure(func() string {
return spew.Sdump(s.pendingSettleFails)
}))