mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-18 14:44:22 +01:00
multi: make AddPreimage variadic, optimistically compute key
In this commit, we modify the WitnessCache's AddPreimage method to accept a variadic number of preimages. This enables callers to batch preimage writes in performance critical areas of the codebase, e.g. the htlcswitch. Additionally, we lift the computation of the witnesses' keys outside of the db transaction. This saves us from having to do hashing inside and blocking other callers, and limits extraneous blocking at the call site.
This commit is contained in:
@@ -274,9 +274,13 @@ type PreimageCache interface {
|
||||
// argument. Otherwise, it'll return false.
|
||||
LookupPreimage(hash []byte) ([]byte, bool)
|
||||
|
||||
// AddPreimage attempts to add a new preimage to the global cache. If
|
||||
// successful a nil error will be returned.
|
||||
AddPreimage(preimage []byte) error
|
||||
// AddPreimages adds a batch of newly discovered preimages to the global
|
||||
// cache, and also signals any subscribers of the newly discovered
|
||||
// witness.
|
||||
//
|
||||
// NOTE: The backing slice of MUST NOT be modified, otherwise the
|
||||
// subscribers may be notified of the incorrect preimages.
|
||||
AddPreimages(preimages ...[]byte) error
|
||||
}
|
||||
|
||||
// WalletDriver represents a "driver" for a particular concrete
|
||||
|
||||
Reference in New Issue
Block a user