Skip to content

Commit cb10233

Browse files
committed
WIP: hive -> isar migration and hive clean up
(cherry picked from commit 42abebe)
1 parent 61ca071 commit cb10233

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

lib/db/hive/db.dart

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ import 'package:stackduo/utilities/enums/coin_enum.dart';
1313
import 'package:stackduo/utilities/logger.dart';
1414

1515
class DB {
16+
// legacy (required for migrations)
17+
@Deprecated("Left over for migration from old versions of Stack Wallet")
1618
static const String boxNameAddressBook = "addressBook";
17-
static const String boxNameDebugInfo = "debugInfoBox";
19+
20+
// in use
21+
// TODO: migrate
1822
static const String boxNameNodeModels = "nodeModels";
1923
static const String boxNamePrimaryNodes = "primaryNodes";
2024
static const String boxNameAllWalletsData = "wallets";
@@ -27,21 +31,19 @@ class DB {
2731
static const String boxNameTradeNotes = "tradeNotesBox";
2832
static const String boxNameTradeLookup = "tradeToTxidLookUpBox";
2933
static const String boxNameFavoriteWallets = "favoriteWallets";
30-
static const String boxNamePrefs = "prefs";
3134
static const String boxNameWalletsToDeleteOnStart = "walletsToDeleteOnStart";
3235
static const String boxNamePriceCache = "priceAPIPrice24hCache";
36+
37+
// in use (keep for now)
3338
static const String boxNameDBInfo = "dbInfo";
34-
// static const String boxNameTheme = "theme";
35-
static const String boxNameDesktopData = "desktopData";
36-
static const String boxNameBuys = "buysBox";
39+
static const String boxNamePrefs = "prefs";
3740

3841
String boxNameTxCache({required Coin coin}) => "${coin.name}_txCache";
3942
String boxNameSetCache({required Coin coin}) =>
4043
"${coin.name}_anonymitySetCache";
4144
String boxNameUsedSerialsCache({required Coin coin}) =>
4245
"${coin.name}_usedSerialsCache";
4346

44-
Box<String>? _boxDebugInfo;
4547
Box<NodeModel>? _boxNodeModels;
4648
Box<NodeModel>? _boxPrimaryNodes;
4749
Box<dynamic>? _boxAllWalletsData;
@@ -56,7 +58,7 @@ class DB {
5658
Box<dynamic>? _boxPrefs;
5759
Box<TradeWalletLookup>? _boxTradeLookup;
5860
Box<dynamic>? _boxDBInfo;
59-
Box<String>? _boxDesktopData;
61+
// Box<String>? _boxDesktopData;
6062

6163
final Map<String, Box<dynamic>> _walletBoxes = {};
6264

@@ -99,8 +101,6 @@ class DB {
99101
_boxPrefs = await Hive.openBox<dynamic>(boxNamePrefs);
100102
}
101103

102-
_boxDebugInfo = await Hive.openBox<String>(boxNameDebugInfo);
103-
104104
if (Hive.isBoxOpen(boxNameNodeModels)) {
105105
_boxNodeModels = Hive.box<NodeModel>(boxNameNodeModels);
106106
} else {
@@ -119,12 +119,6 @@ class DB {
119119
_boxAllWalletsData = await Hive.openBox<dynamic>(boxNameAllWalletsData);
120120
}
121121

122-
if (Hive.isBoxOpen(boxNameDesktopData)) {
123-
_boxDesktopData = Hive.box<String>(boxNameDesktopData);
124-
} else {
125-
_boxDesktopData = await Hive.openBox<String>(boxNameDesktopData);
126-
}
127-
128122
_boxNotifications =
129123
await Hive.openBox<NotificationModel>(boxNameNotifications);
130124
_boxWatchedTransactions =
@@ -248,7 +242,7 @@ class DB {
248242
Future<bool> deleteEverything() async {
249243
try {
250244
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAddressBook);
251-
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameDebugInfo);
245+
await DB.instance.deleteBoxFromDisk(boxName: "debugInfoBox");
252246
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNodeModels);
253247
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrimaryNodes);
254248
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAllWalletsData);

0 commit comments

Comments
 (0)