From fe3c3642e296db13a2abc35bffdfcfeca7166cdf Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 11 Apr 2017 21:18:22 -0700 Subject: [PATCH] channeldb: use the Batch method when writing payment details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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! --- channeldb/payments.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channeldb/payments.go b/channeldb/payments.go index 75b5731f..a8d286b8 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -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