Skip to content

Commit

Permalink
channeldb: use the Batch method when writing payment details
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
Roasbeef committed Apr 12, 2017
1 parent a22ba92 commit fe3c364
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion channeldb/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fe3c364

Please sign in to comment.