channeldb: use the Batch method when writing payment details

This commit implements an easy optimization by using bolt db’s Batch
method when writing payment details to disk. The AddPaymnent method can
be concurrently called by thousands of grouting due to the way the
payment dispatch pipeline is architected. With this commit, we shave of
a significant amount of running time when users are sending thousands
of payments a second as what would’ve been thousands of writes can now
be coalesced into one or two writes!
This commit is contained in:
Olaoluwa Osuntokun 2017-04-11 21:18:22 -07:00
parent a22ba92630
commit fe3c3642e2
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -62,7 +62,7 @@ func (db *DB) AddPayment(payment *OutgoingPayment) error {
}
paymentBytes := b.Bytes()
return db.Update(func(tx *bolt.Tx) error {
return db.Batch(func(tx *bolt.Tx) error {
payments, err := tx.CreateBucketIfNotExists(paymentBucket)
if err != nil {
return err