Skip to content

Commit a45da99

Browse files
committed
Merge remote-tracking branch 'benma/revert'
2 parents d53a302 + 16638ca commit a45da99

File tree

17 files changed

+15
-205
lines changed

17 files changed

+15
-205
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Changelog
22

33
## [Unreleased]
4-
- Gracefully deal with corrupt bbolt database files
54

65
## 4.35.0
76
- Render number of blocks scanned and percentage progress using fixed-width digits for a more stable UI

backend/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func NewBackend(arguments *arguments.Arguments, environment Environment) (*Backe
196196
aopp: AOPP{State: aoppStateInactive},
197197
log: log,
198198
}
199-
notifier, err := NewNotifier(filepath.Join(arguments.MainDirectoryPath(), "notifier.db"), log)
199+
notifier, err := NewNotifier(filepath.Join(arguments.MainDirectoryPath(), "notifier.db"))
200200
if err != nil {
201201
return nil, err
202202
}

backend/coins/btc/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func (account *Account) Initialize() error {
292292

293293
dbName := fmt.Sprintf("%s.db", accountIdentifier)
294294
account.log.Debugf("Opening the database '%s' to persist the transactions.", dbName)
295-
db, err := transactionsdb.NewDB(path.Join(account.Config().DBFolder, dbName), account.log)
295+
db, err := transactionsdb.NewDB(path.Join(account.Config().DBFolder, dbName))
296296
if err != nil {
297297
return err
298298
}

backend/coins/btc/db/transactionsdb/transactionsdb.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/transactions"
2727
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/types"
2828
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/util"
29-
"github.com/digitalbitbox/bitbox-wallet-app/util/bolt"
3029
"github.com/digitalbitbox/bitbox-wallet-app/util/errp"
31-
"github.com/sirupsen/logrus"
3230
"go.etcd.io/bbolt"
3331
)
3432

@@ -47,8 +45,8 @@ type DB struct {
4745
}
4846

4947
// NewDB creates/opens a new db.
50-
func NewDB(filename string, log *logrus.Entry) (*DB, error) {
51-
db, err := bolt.Open(filename, log)
48+
func NewDB(filename string) (*DB, error) {
49+
db, err := bbolt.Open(filename, 0600, nil)
5250
if err != nil {
5351
return nil, errp.WithStack(err)
5452
}

backend/coins/btc/db/transactionsdb/transactionsdb_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ import (
2626
"github.com/btcsuite/btcd/wire"
2727
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/blockchain"
2828
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/types"
29-
"github.com/digitalbitbox/bitbox-wallet-app/util/logging"
3029
"github.com/digitalbitbox/bitbox-wallet-app/util/test"
3130
"github.com/stretchr/testify/require"
3231
)
3332

3433
func getDB() *DB {
35-
db, err := NewDB(path.Join(test.TstTempDir("transactionsdb_test"), "testdb"),
36-
logging.Get().WithGroup("transactionsdb_test"))
34+
db, err := NewDB(path.Join(test.TstTempDir("transactionsdb_test"), "testdb"))
3735
if err != nil {
3836
panic(err)
3937
}

backend/coins/btc/transactions/transactions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (s *transactionsSuite) SetupTest() {
9999
_, s.addressChain = addressesTest.NewAddressChain()
100100
s.synchronizer = synchronizer.NewSynchronizer(func() {}, func() {}, s.log)
101101
s.blockchainMock = NewBlockchainMock()
102-
db, err := transactionsdb.NewDB(test.TstTempFile("bitbox-wallet-db-"), s.log)
102+
db, err := transactionsdb.NewDB(test.TstTempFile("bitbox-wallet-db-"))
103103
if err != nil {
104104
panic(err)
105105
}

backend/coins/eth/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (account *Account) Initialize() error {
158158

159159
dbName := fmt.Sprintf("%s.db", accountIdentifier)
160160
account.log.Debugf("Opening the database '%s' to persist the transactions.", dbName)
161-
db, err := db.NewDB(path.Join(account.Config().DBFolder, dbName), account.log)
161+
db, err := db.NewDB(path.Join(account.Config().DBFolder, dbName))
162162
if err != nil {
163163
return err
164164
}

backend/coins/eth/db/db.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ import (
2020
"sort"
2121

2222
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/eth/types"
23-
"github.com/digitalbitbox/bitbox-wallet-app/util/bolt"
2423
"github.com/digitalbitbox/bitbox-wallet-app/util/errp"
2524
"github.com/digitalbitbox/bitbox-wallet-app/util/jsonp"
26-
"github.com/sirupsen/logrus"
2725
"go.etcd.io/bbolt"
2826
)
2927

@@ -37,8 +35,8 @@ type DB struct {
3735
}
3836

3937
// NewDB creates/opens a new db.
40-
func NewDB(filename string, log *logrus.Entry) (*DB, error) {
41-
db, err := bolt.Open(filename, log)
38+
func NewDB(filename string) (*DB, error) {
39+
db, err := bbolt.Open(filename, 0600, nil)
4240
if err != nil {
4341
return nil, err
4442
}

backend/notifier.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import (
1818
"fmt"
1919

2020
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts"
21-
"github.com/digitalbitbox/bitbox-wallet-app/util/bolt"
2221
"github.com/digitalbitbox/bitbox-wallet-app/util/errp"
23-
"github.com/sirupsen/logrus"
2422
"go.etcd.io/bbolt"
2523
)
2624

@@ -35,8 +33,8 @@ type Notifier struct {
3533
}
3634

3735
// NewNotifier returns a new Notifier.
38-
func NewNotifier(dbFilename string, log *logrus.Entry) (*Notifier, error) {
39-
db, err := bolt.Open(dbFilename, log)
36+
func NewNotifier(dbFilename string) (*Notifier, error) {
37+
db, err := bbolt.Open(dbFilename, 0600, nil)
4038
if err != nil {
4139
return nil, errp.WithStack(err)
4240
}

backend/rates/db.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
"path/filepath"
77
"time"
88

9-
"github.com/digitalbitbox/bitbox-wallet-app/util/bolt"
10-
"github.com/sirupsen/logrus"
119
"go.etcd.io/bbolt"
1210
)
1311

14-
func openRatesDB(dir string, log *logrus.Entry) (*bbolt.DB, error) {
15-
return bolt.Open(filepath.Join(dir, "rates.db"), log)
12+
func openRatesDB(dir string) (*bbolt.DB, error) {
13+
opt := &bbolt.Options{Timeout: 5 * time.Second} // network disks may take long
14+
return bbolt.Open(filepath.Join(dir, "rates.db"), 0600, opt)
1615
}
1716

1817
// loadHistoryBucket loads data from an updater.historyDB bucket identified by the key.

0 commit comments

Comments
 (0)