Skip to content

Commit 650ef2f

Browse files
accounts: export kvdb DB
1 parent dbc73ce commit 650ef2f

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

accounts/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ func (s *InterceptorService) CreditAccount(ctx context.Context,
361361
return nil, ErrAccountServiceDisabled
362362
}
363363

364-
// Credit the account in the db.
364+
// Credit the account in the DB.
365365
err := s.store.CreditAccount(ctx, accountID, amount)
366366
if err != nil {
367367
return nil, fmt.Errorf("unable to credit account: %w", err)
@@ -386,7 +386,7 @@ func (s *InterceptorService) DebitAccount(ctx context.Context,
386386
return nil, ErrAccountServiceDisabled
387387
}
388388

389-
// Debit the account in the db.
389+
// Debit the account in the DB.
390390
err := s.store.DebitAccount(ctx, accountID, amount)
391391
if err != nil {
392392
return nil, fmt.Errorf("unable to debit account: %w", err)

accounts/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func TestAccountService(t *testing.T) {
246246

247247
// Ensure that the service was started successfully and
248248
// still running though, despite the closing of the
249-
// db store.
249+
// DB store.
250250
require.True(t, s.IsRunning())
251251

252252
// Now let's send the invoice update, which should fail.

accounts/sql_migration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func TestAccountStoreMigration(t *testing.T) {
301301
)
302302
require.NoError(t, err)
303303
t.Cleanup(func() {
304-
require.NoError(t, kvStore.db.Close())
304+
require.NoError(t, kvStore.DB.Close())
305305
})
306306

307307
// Populate the kv store.
@@ -340,7 +340,7 @@ func TestAccountStoreMigration(t *testing.T) {
340340
ctx, &opts,
341341
func(tx SQLMig6Queries) error {
342342
return MigrateAccountStoreToSQL(
343-
ctx, kvStore.db, tx,
343+
ctx, kvStore.DB, tx,
344344
)
345345
}, sqldb.NoOpReset,
346346
)
@@ -444,7 +444,7 @@ func rapidRandomizeAccounts(t *testing.T, kvStore *BoltStore) {
444444
acct := makeAccountGen().Draw(t, "account")
445445

446446
// Then proceed to insert the account with its invoices and
447-
// payments into the db
447+
// payments into the DB
448448
newAcct, err := kvStore.NewAccount(
449449
ctx, acct.balance, acct.expiry, acct.label,
450450
)

accounts/store_kvdb.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
// DBFilename is the filename within the data directory which contains
2626
// the macaroon stores.
27-
DBFilename = "accounts.db"
27+
DBFilename = "accounts.DB"
2828

2929
// dbPathPermission is the default permission the account database
3030
// directory is created with (if it does not exist).
@@ -60,7 +60,7 @@ var (
6060

6161
// BoltStore wraps the bolt DB that stores all accounts and their balances.
6262
type BoltStore struct {
63-
db kvdb.Backend
63+
DB kvdb.Backend
6464
clock clock.Clock
6565
}
6666

@@ -101,7 +101,7 @@ func NewBoltStore(dir, fileName string, clock clock.Clock) (*BoltStore, error) {
101101

102102
// Return the DB wrapped in a BoltStore object.
103103
return &BoltStore{
104-
db: db,
104+
DB: db,
105105
clock: clock,
106106
}, nil
107107
}
@@ -110,7 +110,7 @@ func NewBoltStore(dir, fileName string, clock clock.Clock) (*BoltStore, error) {
110110
//
111111
// NOTE: This is part of the Store interface.
112112
func (s *BoltStore) Close() error {
113-
return s.db.Close()
113+
return s.DB.Close()
114114
}
115115

116116
// NewAccount creates a new OffChainBalanceAccount with the given balance and a
@@ -162,7 +162,7 @@ func (s *BoltStore) NewAccount(ctx context.Context, balance lnwire.MilliSatoshi,
162162

163163
// Try storing the account in the account database, so we can keep track
164164
// of its balance.
165-
err := s.db.Update(func(tx walletdb.ReadWriteTx) error {
165+
err := s.DB.Update(func(tx walletdb.ReadWriteTx) error {
166166
bucket := tx.ReadWriteBucket(accountBucketName)
167167
if bucket == nil {
168168
return ErrAccountBucketNotFound
@@ -364,7 +364,7 @@ func (s *BoltStore) DeleteAccountPayment(_ context.Context, id AccountID,
364364
func (s *BoltStore) updateAccount(id AccountID,
365365
updateFn func(*OffChainBalanceAccount) error) error {
366366

367-
return s.db.Update(func(tx kvdb.RwTx) error {
367+
return s.DB.Update(func(tx kvdb.RwTx) error {
368368
bucket := tx.ReadWriteBucket(accountBucketName)
369369
if bucket == nil {
370370
return ErrAccountBucketNotFound
@@ -451,7 +451,7 @@ func (s *BoltStore) Account(_ context.Context, id AccountID) (
451451
// Try looking up and reading the account by its ID from the local
452452
// bolt DB.
453453
var accountBinary []byte
454-
err := s.db.View(func(tx kvdb.RTx) error {
454+
err := s.DB.View(func(tx kvdb.RTx) error {
455455
bucket := tx.ReadBucket(accountBucketName)
456456
if bucket == nil {
457457
return ErrAccountBucketNotFound
@@ -487,7 +487,7 @@ func (s *BoltStore) Accounts(_ context.Context) ([]*OffChainBalanceAccount,
487487
error) {
488488

489489
var accounts []*OffChainBalanceAccount
490-
err := s.db.View(func(tx kvdb.RTx) error {
490+
err := s.DB.View(func(tx kvdb.RTx) error {
491491
// This function will be called in the ForEach and receive
492492
// the key and value of each account in the DB. The key, which
493493
// is also the ID is not used because it is also marshaled into
@@ -531,7 +531,7 @@ func (s *BoltStore) Accounts(_ context.Context) ([]*OffChainBalanceAccount,
531531
//
532532
// NOTE: This is part of the Store interface.
533533
func (s *BoltStore) RemoveAccount(_ context.Context, id AccountID) error {
534-
return s.db.Update(func(tx kvdb.RwTx) error {
534+
return s.DB.Update(func(tx kvdb.RwTx) error {
535535
bucket := tx.ReadWriteBucket(accountBucketName)
536536
if bucket == nil {
537537
return ErrAccountBucketNotFound
@@ -554,7 +554,7 @@ func (s *BoltStore) LastIndexes(_ context.Context) (uint64, uint64, error) {
554554
var (
555555
addValue, settleValue []byte
556556
)
557-
err := s.db.View(func(tx kvdb.RTx) error {
557+
err := s.DB.View(func(tx kvdb.RTx) error {
558558
bucket := tx.ReadBucket(accountBucketName)
559559
if bucket == nil {
560560
return ErrAccountBucketNotFound
@@ -592,7 +592,7 @@ func (s *BoltStore) StoreLastIndexes(_ context.Context, addIndex,
592592
byteOrder.PutUint64(addValue, addIndex)
593593
byteOrder.PutUint64(settleValue, settleIndex)
594594

595-
return s.db.Update(func(tx kvdb.RwTx) error {
595+
return s.DB.Update(func(tx kvdb.RwTx) error {
596596
bucket := tx.ReadWriteBucket(accountBucketName)
597597
if bucket == nil {
598598
return ErrAccountBucketNotFound

accounts/test_kvdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func NewTestDBFromPath(t *testing.T, dbPath string,
2828
require.NoError(t, err)
2929

3030
t.Cleanup(func() {
31-
require.NoError(t, store.db.Close())
31+
require.NoError(t, store.DB.Close())
3232
})
3333

3434
return store

0 commit comments

Comments
 (0)