channeldb+routing: cache circuit and onion blob for htlc attempt

This commit caches the creation of sphinx circuit and onion blob to
avoid re-creating them again.
This commit is contained in:
yyforyongyu committed 2025-02-10 11:28:23 +08:00
1 parent 46eb811543
commit f96eb50ca8
8 files changed
+187 -121

No files matched your search

+11 -3
View File
@@ -535,15 +535,23 @@ func genInfo() (*channeldb.PaymentCreationInfo, *channeldb.HTLCAttemptInfo,
}
rhash := sha256.Sum256(preimage[:])
var hash lntypes.Hash
copy(hash[:], rhash[:])
attempt, err := channeldb.NewHtlcAttempt(
1, priv, testRoute, time.Time{}, &hash,
)
if err != nil {
return nil, nil, lntypes.Preimage{}, err
}
return &channeldb.PaymentCreationInfo{
PaymentIdentifier: rhash,
Value: testRoute.ReceiverAmt(),
CreationTime: time.Unix(time.Now().Unix(), 0),
PaymentRequest: []byte("hola"),
},
&channeldb.NewHtlcAttempt(
1, priv, testRoute, time.Time{}, nil,
).HTLCAttemptInfo, preimage, nil
&attempt.HTLCAttemptInfo, preimage, nil
}
func genPreimage() ([32]byte, error) {