mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
Merge pull request #1486 from Roasbeef/minor-forwarding-perf-improvements
htlcswitch+routing: minor forwarding perf improvements
This commit is contained in:
commit
3c1d06d54a
@ -1566,8 +1566,13 @@ func (l *channelLink) updateCommitTx() error {
|
||||
if err == lnwallet.ErrNoWindow {
|
||||
l.tracef("revocation window exhausted, unable to send: %v, "+
|
||||
"dangling_opens=%v, dangling_closes%v",
|
||||
l.batchCounter, spew.Sdump(l.openedCircuits),
|
||||
spew.Sdump(l.closedCircuits))
|
||||
l.batchCounter, newLogClosure(func() string {
|
||||
return spew.Sdump(l.openedCircuits)
|
||||
}),
|
||||
newLogClosure(func() string {
|
||||
return spew.Sdump(l.closedCircuits)
|
||||
}),
|
||||
)
|
||||
return nil
|
||||
} else if err != nil {
|
||||
return err
|
||||
|
@ -1251,7 +1251,7 @@ func (s *Switch) closeCircuit(pkt *htlcPacket) (*PaymentCircuit, error) {
|
||||
// we're the originator of the payment, so the link stops attempting to
|
||||
// re-broadcast.
|
||||
func (s *Switch) ackSettleFail(settleFailRef channeldb.SettleFailRef) error {
|
||||
return s.cfg.DB.Update(func(tx *bolt.Tx) error {
|
||||
return s.cfg.DB.Batch(func(tx *bolt.Tx) error {
|
||||
return s.cfg.SwitchPackager.AckSettleFails(tx, settleFailRef)
|
||||
})
|
||||
}
|
||||
|
@ -1458,7 +1458,10 @@ func generateSphinxPacket(route *Route, paymentHash []byte) ([]byte,
|
||||
hopPayloads := route.ToHopPayloads()
|
||||
|
||||
log.Tracef("Constructed per-hop payloads for payment_hash=%x: %v",
|
||||
paymentHash[:], spew.Sdump(hopPayloads))
|
||||
paymentHash[:], newLogClosure(func() string {
|
||||
return spew.Sdump(hopPayloads)
|
||||
}),
|
||||
)
|
||||
|
||||
sessionKey, err := btcec.NewPrivateKey(btcec.S256())
|
||||
if err != nil {
|
||||
@ -1467,8 +1470,9 @@ func generateSphinxPacket(route *Route, paymentHash []byte) ([]byte,
|
||||
|
||||
// Next generate the onion routing packet which allows us to perform
|
||||
// privacy preserving source routing across the network.
|
||||
sphinxPacket, err := sphinx.NewOnionPacket(nodes, sessionKey,
|
||||
hopPayloads, paymentHash)
|
||||
sphinxPacket, err := sphinx.NewOnionPacket(
|
||||
nodes, sessionKey, hopPayloads, paymentHash,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
19
rpcserver.go
19
rpcserver.go
@ -11,11 +11,11 @@ import (
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/coreos/bbolt"
|
||||
@ -51,6 +51,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
zeroHash [32]byte
|
||||
|
||||
// maxPaymentMSat is the maximum allowed payment currently permitted as
|
||||
// defined in BOLT-002. This value depends on which chain is active.
|
||||
// It is set to the value under the Bitcoin chain as default.
|
||||
@ -2061,9 +2063,10 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error
|
||||
|
||||
payIntent.cltvDelta = uint16(rpcPayReq.FinalCltvDelta)
|
||||
|
||||
// If the user is manually specifying payment details, then the
|
||||
// payment hash may be encoded as a string.
|
||||
if rpcPayReq.PaymentHashString != "" {
|
||||
// If the user is manually specifying payment details, then the payment
|
||||
// hash may be encoded as a string.
|
||||
switch {
|
||||
case rpcPayReq.PaymentHashString != "":
|
||||
paymentHash, err := hex.DecodeString(
|
||||
rpcPayReq.PaymentHashString,
|
||||
)
|
||||
@ -2072,15 +2075,15 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error
|
||||
}
|
||||
|
||||
copy(payIntent.rHash[:], paymentHash)
|
||||
} else {
|
||||
copy(payIntent.rHash[:], rpcPayReq.PaymentHash)
|
||||
}
|
||||
|
||||
// If we're in debug HTLC mode, then all outgoing HTLCs will pay to the
|
||||
// same debug rHash. Otherwise, we pay to the rHash specified within
|
||||
// the RPC request.
|
||||
if cfg.DebugHTLC && len(payIntent.rHash) == 0 {
|
||||
case cfg.DebugHTLC && bytes.Equal(payIntent.rHash[:], zeroHash[:]):
|
||||
copy(payIntent.rHash[:], debugHash[:])
|
||||
|
||||
default:
|
||||
copy(payIntent.rHash[:], rpcPayReq.PaymentHash)
|
||||
}
|
||||
|
||||
// Currently, within the bootstrap phase of the network, we limit the
|
||||
|
Loading…
Reference in New Issue
Block a user