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 {
|
if err == lnwallet.ErrNoWindow {
|
||||||
l.tracef("revocation window exhausted, unable to send: %v, "+
|
l.tracef("revocation window exhausted, unable to send: %v, "+
|
||||||
"dangling_opens=%v, dangling_closes%v",
|
"dangling_opens=%v, dangling_closes%v",
|
||||||
l.batchCounter, spew.Sdump(l.openedCircuits),
|
l.batchCounter, newLogClosure(func() string {
|
||||||
spew.Sdump(l.closedCircuits))
|
return spew.Sdump(l.openedCircuits)
|
||||||
|
}),
|
||||||
|
newLogClosure(func() string {
|
||||||
|
return spew.Sdump(l.closedCircuits)
|
||||||
|
}),
|
||||||
|
)
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
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
|
// we're the originator of the payment, so the link stops attempting to
|
||||||
// re-broadcast.
|
// re-broadcast.
|
||||||
func (s *Switch) ackSettleFail(settleFailRef channeldb.SettleFailRef) error {
|
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)
|
return s.cfg.SwitchPackager.AckSettleFails(tx, settleFailRef)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1458,7 +1458,10 @@ func generateSphinxPacket(route *Route, paymentHash []byte) ([]byte,
|
|||||||
hopPayloads := route.ToHopPayloads()
|
hopPayloads := route.ToHopPayloads()
|
||||||
|
|
||||||
log.Tracef("Constructed per-hop payloads for payment_hash=%x: %v",
|
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())
|
sessionKey, err := btcec.NewPrivateKey(btcec.S256())
|
||||||
if err != nil {
|
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
|
// Next generate the onion routing packet which allows us to perform
|
||||||
// privacy preserving source routing across the network.
|
// privacy preserving source routing across the network.
|
||||||
sphinxPacket, err := sphinx.NewOnionPacket(nodes, sessionKey,
|
sphinxPacket, err := sphinx.NewOnionPacket(
|
||||||
hopPayloads, paymentHash)
|
nodes, sessionKey, hopPayloads, paymentHash,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
19
rpcserver.go
19
rpcserver.go
@ -11,11 +11,11 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/macaroon-bakery.v2/bakery"
|
"gopkg.in/macaroon-bakery.v2/bakery"
|
||||||
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/coreos/bbolt"
|
"github.com/coreos/bbolt"
|
||||||
@ -51,6 +51,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
zeroHash [32]byte
|
||||||
|
|
||||||
// maxPaymentMSat is the maximum allowed payment currently permitted as
|
// maxPaymentMSat is the maximum allowed payment currently permitted as
|
||||||
// defined in BOLT-002. This value depends on which chain is active.
|
// defined in BOLT-002. This value depends on which chain is active.
|
||||||
// It is set to the value under the Bitcoin chain as default.
|
// 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)
|
payIntent.cltvDelta = uint16(rpcPayReq.FinalCltvDelta)
|
||||||
|
|
||||||
// If the user is manually specifying payment details, then the
|
// If the user is manually specifying payment details, then the payment
|
||||||
// payment hash may be encoded as a string.
|
// hash may be encoded as a string.
|
||||||
if rpcPayReq.PaymentHashString != "" {
|
switch {
|
||||||
|
case rpcPayReq.PaymentHashString != "":
|
||||||
paymentHash, err := hex.DecodeString(
|
paymentHash, err := hex.DecodeString(
|
||||||
rpcPayReq.PaymentHashString,
|
rpcPayReq.PaymentHashString,
|
||||||
)
|
)
|
||||||
@ -2072,15 +2075,15 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
copy(payIntent.rHash[:], paymentHash)
|
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
|
// 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
|
// same debug rHash. Otherwise, we pay to the rHash specified within
|
||||||
// the RPC request.
|
// the RPC request.
|
||||||
if cfg.DebugHTLC && len(payIntent.rHash) == 0 {
|
case cfg.DebugHTLC && bytes.Equal(payIntent.rHash[:], zeroHash[:]):
|
||||||
copy(payIntent.rHash[:], debugHash[:])
|
copy(payIntent.rHash[:], debugHash[:])
|
||||||
|
|
||||||
|
default:
|
||||||
|
copy(payIntent.rHash[:], rpcPayReq.PaymentHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently, within the bootstrap phase of the network, we limit the
|
// Currently, within the bootstrap phase of the network, we limit the
|
||||||
|
Loading…
Reference in New Issue
Block a user