mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 17:51:33 +02:00
channeldb: embed the instance of boltb within DB struct
This commit modifies the composition of the boltdb pointer within the DB struct to use embedding. The rationale for this change is that the daemon may soon store some semi-transient items within the database which requires us to expose the boltdb’s transaction API. The logic for serialization of this data will likely lie outside of the channeldb package as the items that may be stored in the future will be specific to the current sub-systems within the daemon and not generic channel related data.
This commit is contained in:
@@ -113,7 +113,7 @@ func (d *DB) AddInvoice(i *Invoice) error {
|
||||
len(i.Receipt))
|
||||
}
|
||||
|
||||
return d.store.Update(func(tx *bolt.Tx) error {
|
||||
return d.Update(func(tx *bolt.Tx) error {
|
||||
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -157,7 +157,7 @@ func (d *DB) AddInvoice(i *Invoice) error {
|
||||
// terms of the payment.
|
||||
func (d *DB) LookupInvoice(paymentHash [32]byte) (*Invoice, error) {
|
||||
var invoice *Invoice
|
||||
err := d.store.View(func(tx *bolt.Tx) error {
|
||||
err := d.View(func(tx *bolt.Tx) error {
|
||||
invoices := tx.Bucket(invoiceBucket)
|
||||
if invoices == nil {
|
||||
return ErrInvoiceNotFound
|
||||
@@ -197,7 +197,7 @@ func (d *DB) LookupInvoice(paymentHash [32]byte) (*Invoice, error) {
|
||||
func (d *DB) FetchAllInvoices(pendingOnly bool) ([]*Invoice, error) {
|
||||
var invoices []*Invoice
|
||||
|
||||
err := d.store.View(func(tx *bolt.Tx) error {
|
||||
err := d.View(func(tx *bolt.Tx) error {
|
||||
invoiceB := tx.Bucket(invoiceBucket)
|
||||
if invoiceB == nil {
|
||||
return ErrNoInvoicesCreated
|
||||
@@ -238,7 +238,7 @@ func (d *DB) FetchAllInvoices(pendingOnly bool) ([]*Invoice, error) {
|
||||
// hash doesn't existing within the database, then the action will fail with a
|
||||
// "not found" error.
|
||||
func (d *DB) SettleInvoice(paymentHash [32]byte) error {
|
||||
return d.store.Update(func(tx *bolt.Tx) error {
|
||||
return d.Update(func(tx *bolt.Tx) error {
|
||||
invoices, err := tx.CreateBucketIfNotExists(invoiceBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user