multi: add SpewLogClosure to avoid code repetition

This commit is contained in:
yyforyongyu
2024-07-25 22:18:00 +08:00
parent b6049ff94b
commit d992cf94d6
19 changed files with 57 additions and 144 deletions

View File

@ -5,7 +5,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btclog"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/channeldb/models"
@ -433,7 +432,7 @@ func (p *paymentSession) UpdateAdditionalEdge(msg *lnwire.ChannelUpdate,
policy.FeeProportionalMillionths = lnwire.MilliSatoshi(msg.FeeRate)
log.Debugf("New private channel update applied: %v",
lnutils.NewLogClosure(func() string { return spew.Sdump(msg) }))
lnutils.SpewLogClosure(msg))
return true
}

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",
req.Amount, req.Target, lnutils.NewLogClosure(func() string {
return spew.Sdump(route)
}),
)
req.Amount, req.Target, lnutils.SpewLogClosure(route))
return route, probability, nil
}
@ -1091,11 +1088,8 @@ func (r *ChannelRouter) sendToRoute(htlcHash lntypes.Hash, rt *route.Route,
return nil, err
}
log.Tracef("Dispatching SendToRoute for HTLC hash %v: %v",
htlcHash, lnutils.NewLogClosure(func() string {
return spew.Sdump(rt)
}),
)
log.Tracef("Dispatching SendToRoute for HTLC hash %v: %v", htlcHash,
lnutils.SpewLogClosure(rt))
// Since the HTLC hashes and preimages are specified manually over the
// RPC for SendToRoute requests, we don't have to worry about creating