mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
WIP: hive -> isar migration and hive clean up
This commit is contained in:
parent
69fabde3a5
commit
42abebe1d2
1 changed files with 10 additions and 16 deletions
|
@ -23,8 +23,12 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
|
||||||
class DB {
|
class DB {
|
||||||
|
// legacy (required for migrations)
|
||||||
|
@Deprecated("Left over for migration from old versions of Stack Wallet")
|
||||||
static const String boxNameAddressBook = "addressBook";
|
static const String boxNameAddressBook = "addressBook";
|
||||||
static const String boxNameDebugInfo = "debugInfoBox";
|
|
||||||
|
// in use
|
||||||
|
// TODO: migrate
|
||||||
static const String boxNameNodeModels = "nodeModels";
|
static const String boxNameNodeModels = "nodeModels";
|
||||||
static const String boxNamePrimaryNodes = "primaryNodes";
|
static const String boxNamePrimaryNodes = "primaryNodes";
|
||||||
static const String boxNameAllWalletsData = "wallets";
|
static const String boxNameAllWalletsData = "wallets";
|
||||||
|
@ -37,13 +41,12 @@ class DB {
|
||||||
static const String boxNameTradeNotes = "tradeNotesBox";
|
static const String boxNameTradeNotes = "tradeNotesBox";
|
||||||
static const String boxNameTradeLookup = "tradeToTxidLookUpBox";
|
static const String boxNameTradeLookup = "tradeToTxidLookUpBox";
|
||||||
static const String boxNameFavoriteWallets = "favoriteWallets";
|
static const String boxNameFavoriteWallets = "favoriteWallets";
|
||||||
static const String boxNamePrefs = "prefs";
|
|
||||||
static const String boxNameWalletsToDeleteOnStart = "walletsToDeleteOnStart";
|
static const String boxNameWalletsToDeleteOnStart = "walletsToDeleteOnStart";
|
||||||
static const String boxNamePriceCache = "priceAPIPrice24hCache";
|
static const String boxNamePriceCache = "priceAPIPrice24hCache";
|
||||||
|
|
||||||
|
// in use (keep for now)
|
||||||
static const String boxNameDBInfo = "dbInfo";
|
static const String boxNameDBInfo = "dbInfo";
|
||||||
// static const String boxNameTheme = "theme";
|
static const String boxNamePrefs = "prefs";
|
||||||
static const String boxNameDesktopData = "desktopData";
|
|
||||||
static const String boxNameBuys = "buysBox";
|
|
||||||
|
|
||||||
String boxNameTxCache({required Coin coin}) => "${coin.name}_txCache";
|
String boxNameTxCache({required Coin coin}) => "${coin.name}_txCache";
|
||||||
String boxNameSetCache({required Coin coin}) =>
|
String boxNameSetCache({required Coin coin}) =>
|
||||||
|
@ -51,7 +54,6 @@ class DB {
|
||||||
String boxNameUsedSerialsCache({required Coin coin}) =>
|
String boxNameUsedSerialsCache({required Coin coin}) =>
|
||||||
"${coin.name}_usedSerialsCache";
|
"${coin.name}_usedSerialsCache";
|
||||||
|
|
||||||
Box<String>? _boxDebugInfo;
|
|
||||||
Box<NodeModel>? _boxNodeModels;
|
Box<NodeModel>? _boxNodeModels;
|
||||||
Box<NodeModel>? _boxPrimaryNodes;
|
Box<NodeModel>? _boxPrimaryNodes;
|
||||||
Box<dynamic>? _boxAllWalletsData;
|
Box<dynamic>? _boxAllWalletsData;
|
||||||
|
@ -66,7 +68,7 @@ class DB {
|
||||||
Box<dynamic>? _boxPrefs;
|
Box<dynamic>? _boxPrefs;
|
||||||
Box<TradeWalletLookup>? _boxTradeLookup;
|
Box<TradeWalletLookup>? _boxTradeLookup;
|
||||||
Box<dynamic>? _boxDBInfo;
|
Box<dynamic>? _boxDBInfo;
|
||||||
Box<String>? _boxDesktopData;
|
// Box<String>? _boxDesktopData;
|
||||||
|
|
||||||
final Map<String, Box<dynamic>> _walletBoxes = {};
|
final Map<String, Box<dynamic>> _walletBoxes = {};
|
||||||
|
|
||||||
|
@ -109,8 +111,6 @@ class DB {
|
||||||
_boxPrefs = await Hive.openBox<dynamic>(boxNamePrefs);
|
_boxPrefs = await Hive.openBox<dynamic>(boxNamePrefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
_boxDebugInfo = await Hive.openBox<String>(boxNameDebugInfo);
|
|
||||||
|
|
||||||
if (Hive.isBoxOpen(boxNameNodeModels)) {
|
if (Hive.isBoxOpen(boxNameNodeModels)) {
|
||||||
_boxNodeModels = Hive.box<NodeModel>(boxNameNodeModels);
|
_boxNodeModels = Hive.box<NodeModel>(boxNameNodeModels);
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,12 +129,6 @@ class DB {
|
||||||
_boxAllWalletsData = await Hive.openBox<dynamic>(boxNameAllWalletsData);
|
_boxAllWalletsData = await Hive.openBox<dynamic>(boxNameAllWalletsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hive.isBoxOpen(boxNameDesktopData)) {
|
|
||||||
_boxDesktopData = Hive.box<String>(boxNameDesktopData);
|
|
||||||
} else {
|
|
||||||
_boxDesktopData = await Hive.openBox<String>(boxNameDesktopData);
|
|
||||||
}
|
|
||||||
|
|
||||||
_boxNotifications =
|
_boxNotifications =
|
||||||
await Hive.openBox<NotificationModel>(boxNameNotifications);
|
await Hive.openBox<NotificationModel>(boxNameNotifications);
|
||||||
_boxWatchedTransactions =
|
_boxWatchedTransactions =
|
||||||
|
@ -258,7 +252,7 @@ class DB {
|
||||||
Future<bool> deleteEverything() async {
|
Future<bool> deleteEverything() async {
|
||||||
try {
|
try {
|
||||||
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAddressBook);
|
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAddressBook);
|
||||||
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameDebugInfo);
|
await DB.instance.deleteBoxFromDisk(boxName: "debugInfoBox");
|
||||||
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNodeModels);
|
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameNodeModels);
|
||||||
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrimaryNodes);
|
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNamePrimaryNodes);
|
||||||
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAllWalletsData);
|
await DB.instance.deleteBoxFromDisk(boxName: DB.boxNameAllWalletsData);
|
||||||
|
|
Loading…
Reference in a new issue