mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
improvements
This commit is contained in:
parent
e737116402
commit
835c7d941b
1 changed files with 14 additions and 7 deletions
|
@ -27,6 +27,14 @@ abstract class TorViewModelBase with Store {
|
|||
stopTor();
|
||||
}
|
||||
});
|
||||
reaction((_) => torConnectionStatus, (TorConnectionStatus status) async {
|
||||
if (status == TorConnectionStatus.connecting) {
|
||||
await disconnectFromNode();
|
||||
}
|
||||
if (status == TorConnectionStatus.connected) {
|
||||
await connectOrDisconnectNodeToProxy(connect: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool torStarted = false;
|
||||
|
@ -62,18 +70,17 @@ abstract class TorViewModelBase with Store {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> disconnectFromNode() async {
|
||||
final appStore = getIt.get<AppStore>();
|
||||
appStore.wallet!.syncStatus = NotConnectedSyncStatus();
|
||||
await appStore.wallet!.connectToNode(node: Node(uri: "http://127.0.0.1"));
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> startTor() async {
|
||||
try {
|
||||
torConnectionStatus = TorConnectionStatus.connecting;
|
||||
|
||||
// stop monero from syncing before tor is connected by connecting to a dummy node:
|
||||
final appStore = getIt.get<AppStore>();
|
||||
if (appStore.wallet != null && appStore.wallet!.type == WalletType.monero) {
|
||||
appStore.wallet!.syncStatus = NotConnectedSyncStatus();
|
||||
await appStore.wallet!.connectToNode(node: Node(uri: "http://127.0.0.1"));
|
||||
}
|
||||
|
||||
if (!torStarted) {
|
||||
torStarted = true;
|
||||
torInstance = await Tor.init();
|
||||
|
|
Loading…
Reference in a new issue