Skip to content

Commit da76c34

Browse files
committed
channeldb: convert invoice settle/cancel calls to use Batch
1 parent e8da6dd commit da76c34

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

channeldb/invoices.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ func (d *DB) AddInvoice(newInvoice *Invoice, paymentHash lntypes.Hash) (
242242
}
243243

244244
var invoiceAddIndex uint64
245-
err := d.Update(func(tx *bbolt.Tx) error {
245+
err := d.Batch(func(tx *bbolt.Tx) error {
246+
invoiceAddIndex = 0
247+
246248
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
247249
if err != nil {
248250
return err
@@ -635,7 +637,9 @@ func (d *DB) AcceptOrSettleInvoice(paymentHash [32]byte,
635637
amtPaid lnwire.MilliSatoshi) (*Invoice, error) {
636638

637639
var settledInvoice *Invoice
638-
err := d.Update(func(tx *bbolt.Tx) error {
640+
err := d.Batch(func(tx *bbolt.Tx) error {
641+
settledInvoice = nil
642+
639643
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
640644
if err != nil {
641645
return err
@@ -714,7 +718,9 @@ func (d *DB) SettleHoldInvoice(preimage lntypes.Preimage) (*Invoice, error) {
714718
// payment hash.
715719
func (d *DB) CancelInvoice(paymentHash lntypes.Hash) (*Invoice, error) {
716720
var canceledInvoice *Invoice
717-
err := d.Update(func(tx *bbolt.Tx) error {
721+
err := d.Batch(func(tx *bbolt.Tx) error {
722+
canceledInvoice = nil
723+
718724
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
719725
if err != nil {
720726
return err

0 commit comments

Comments
 (0)