mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 18:21:08 +00:00
32 lines
871 B
Dart
32 lines
871 B
Dart
import 'package:isar/isar.dart';
|
|
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
|
import 'package:stackwallet/utilities/stack_file_system.dart';
|
|
|
|
mixin WalletDB {
|
|
Isar? _isar;
|
|
|
|
Isar get isar => _isar!;
|
|
|
|
/// open the db if it was not already open
|
|
/// returns true if the db was not yet open
|
|
/// returns false if the db was already open
|
|
Future<bool> isarInit(String walletId) async {
|
|
if (_isar != null && isar.isOpen) return false;
|
|
_isar = await Isar.open(
|
|
[
|
|
TransactionSchema,
|
|
TransactionNoteSchema,
|
|
InputSchema,
|
|
OutputSchema,
|
|
UTXOSchema,
|
|
AddressSchema,
|
|
],
|
|
directory: (await StackFileSystem.applicationIsarDirectory()).path,
|
|
inspector: false,
|
|
name: walletId,
|
|
);
|
|
return true;
|
|
}
|
|
|
|
Future<bool> isarClose() async => await _isar?.close() ?? false;
|
|
}
|