@@ -33,11 +33,11 @@ class DB {
33
33
static const String boxNameTrades = "exchangeTransactionsBox" ;
34
34
static const String boxNameAllWalletsData = "wallets" ;
35
35
static const String boxNameFavoriteWallets = "favoriteWallets" ;
36
+ static const String boxNamePrimaryNodesDeprecated = "primaryNodes" ;
36
37
37
38
// in use
38
39
// TODO: migrate
39
40
static const String boxNameNodeModels = "nodeModels" ;
40
- static const String boxNamePrimaryNodes = "primaryNodes" ;
41
41
static const String boxNameNotifications = "notificationModels" ;
42
42
static const String boxNameWatchedTransactions =
43
43
"watchedTxNotificationModels" ;
@@ -127,29 +127,27 @@ class DB {
127
127
_boxNodeModels = await hive.openBox <NodeModel >(boxNameNodeModels);
128
128
}
129
129
130
- if (hive.isBoxOpen (boxNamePrimaryNodes)) {
131
- _boxPrimaryNodes = hive.box <NodeModel >(boxNamePrimaryNodes);
132
- } else {
133
- _boxPrimaryNodes = await hive.openBox <NodeModel >(boxNamePrimaryNodes);
134
- }
135
-
136
130
if (hive.isBoxOpen (boxNameAllWalletsData)) {
137
131
_boxAllWalletsData = hive.box <dynamic >(boxNameAllWalletsData);
138
132
} else {
139
133
_boxAllWalletsData = await hive.openBox <dynamic >(boxNameAllWalletsData);
140
134
}
141
135
142
- _boxNotifications =
143
- await hive.openBox <NotificationModel >(boxNameNotifications);
144
- _boxWatchedTransactions =
145
- await hive.openBox <NotificationModel >(boxNameWatchedTransactions);
146
- _boxWatchedTrades =
147
- await hive.openBox <NotificationModel >(boxNameWatchedTrades);
136
+ _boxNotifications = await hive.openBox <NotificationModel >(
137
+ boxNameNotifications,
138
+ );
139
+ _boxWatchedTransactions = await hive.openBox <NotificationModel >(
140
+ boxNameWatchedTransactions,
141
+ );
142
+ _boxWatchedTrades = await hive.openBox <NotificationModel >(
143
+ boxNameWatchedTrades,
144
+ );
148
145
_boxTradesV2 = await hive.openBox <Trade >(boxNameTradesV2);
149
146
_boxTradeNotes = await hive.openBox <String >(boxNameTradeNotes);
150
147
_boxTradeLookup = await hive.openBox <TradeWalletLookup >(boxNameTradeLookup);
151
148
_walletInfoSource = await hive.openBox< lib_monero_compat.WalletInfo > (
152
- lib_monero_compat.WalletInfo .boxName);
149
+ lib_monero_compat.WalletInfo .boxName,
150
+ );
153
151
_boxFavoriteWallets = await hive.openBox <String >(boxNameFavoriteWallets);
154
152
155
153
await Future .wait ([
@@ -183,11 +181,13 @@ class DB {
183
181
184
182
for (final entry in mapped.entries) {
185
183
if (hive.isBoxOpen (entry.value.walletId)) {
186
- _walletBoxes[entry.value.walletId] =
187
- hive.box <dynamic >(entry.value.walletId);
184
+ _walletBoxes[entry.value.walletId] = hive.box <dynamic >(
185
+ entry.value.walletId,
186
+ );
188
187
} else {
189
- _walletBoxes[entry.value.walletId] =
190
- await hive.openBox <dynamic >(entry.value.walletId);
188
+ _walletBoxes[entry.value.walletId] = await hive.openBox <dynamic >(
189
+ entry.value.walletId,
190
+ );
191
191
}
192
192
}
193
193
}
@@ -196,8 +196,9 @@ class DB {
196
196
if (_txCacheBoxes[currency.identifier]? .isOpen != true ) {
197
197
_txCacheBoxes.remove (currency.identifier);
198
198
}
199
- return _txCacheBoxes[currency.identifier] ?? =
200
- await hive.openBox <dynamic >(_boxNameTxCache (currency: currency));
199
+ return _txCacheBoxes[currency.identifier] ?? = await hive.openBox <dynamic >(
200
+ _boxNameTxCache (currency: currency),
201
+ );
201
202
}
202
203
203
204
Future <void > closeTxCacheBox ({required CryptoCurrency currency}) async {
@@ -210,8 +211,9 @@ class DB {
210
211
if (_setCacheBoxes[currency.identifier]? .isOpen != true ) {
211
212
_setCacheBoxes.remove (currency.identifier);
212
213
}
213
- return _setCacheBoxes[currency.identifier] ?? =
214
- await hive.openBox <dynamic >(_boxNameSetCache (currency: currency));
214
+ return _setCacheBoxes[currency.identifier] ?? = await hive.openBox <dynamic >(
215
+ _boxNameSetCache (currency: currency),
216
+ );
215
217
}
216
218
217
219
Future <void > closeAnonymitySetCacheBox ({
@@ -226,10 +228,8 @@ class DB {
226
228
if (_usedSerialsCacheBoxes[currency.identifier]? .isOpen != true ) {
227
229
_usedSerialsCacheBoxes.remove (currency.identifier);
228
230
}
229
- return _usedSerialsCacheBoxes[currency.identifier] ?? =
230
- await hive.openBox <dynamic >(
231
- _boxNameUsedSerialsCache (currency: currency),
232
- );
231
+ return _usedSerialsCacheBoxes[currency.identifier] ?? = await hive
232
+ .openBox <dynamic >(_boxNameUsedSerialsCache (currency: currency));
233
233
}
234
234
235
235
Future <void > closeUsedSerialsCacheBox ({
@@ -274,10 +274,7 @@ class DB {
274
274
List <T > values <T >({required String boxName}) =>
275
275
hive.box <T >(boxName).values.toList (growable: false );
276
276
277
- T ? get <T >({
278
- required String boxName,
279
- required dynamic key,
280
- }) =>
277
+ T ? get <T >({required String boxName, required dynamic key}) =>
281
278
hive.box <T >(boxName).get (key);
282
279
283
280
bool containsKey <T >({required String boxName, required dynamic key}) =>
@@ -289,19 +286,19 @@ class DB {
289
286
required String boxName,
290
287
required dynamic key,
291
288
required T value,
292
- }) async =>
293
- await mutex
294
- . protect (() async => await hive. box < T >(boxName). put (key, value) );
289
+ }) async => await mutex. protect (
290
+ () async => await hive. box < T >(boxName). put (key, value),
291
+ );
295
292
296
293
Future <void > add <T >({required String boxName, required T value}) async =>
297
294
await mutex.protect (() async => await hive.box <T >(boxName).add (value));
298
295
299
296
Future <void > addAll <T >({
300
297
required String boxName,
301
298
required Iterable <T > values,
302
- }) async =>
303
- await mutex
304
- . protect (() async => await hive. box < T >(boxName). addAll (values) );
299
+ }) async => await mutex. protect (
300
+ () async => await hive. box < T >(boxName). addAll (values),
301
+ );
305
302
306
303
Future <void > delete <T >({
307
304
required dynamic key,
@@ -325,20 +322,21 @@ class DB {
325
322
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameAddressBook);
326
323
await DB .instance.deleteBoxFromDisk (boxName: "debugInfoBox" );
327
324
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameNodeModels);
328
- await DB .instance.deleteBoxFromDisk (boxName: DB .boxNamePrimaryNodes);
329
325
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameAllWalletsData);
330
326
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameNotifications);
331
- await DB .instance
332
- .deleteBoxFromDisk (boxName: DB .boxNameWatchedTransactions);
327
+ await DB .instance.deleteBoxFromDisk (
328
+ boxName: DB .boxNameWatchedTransactions,
329
+ );
333
330
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameWatchedTrades);
334
331
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameTrades);
335
332
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameTradesV2);
336
333
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameTradeNotes);
337
334
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameTradeLookup);
338
335
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameFavoriteWallets);
339
336
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNamePrefs);
340
- await DB .instance
341
- .deleteBoxFromDisk (boxName: DB .boxNameWalletsToDeleteOnStart);
337
+ await DB .instance.deleteBoxFromDisk (
338
+ boxName: DB .boxNameWalletsToDeleteOnStart,
339
+ );
342
340
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNamePriceCache);
343
341
await DB .instance.deleteBoxFromDisk (boxName: DB .boxNameDBInfo);
344
342
await DB .instance.deleteBoxFromDisk (boxName: "theme" );
0 commit comments