mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-05 18:39:25 +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();
|
stopTor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
reaction((_) => torConnectionStatus, (TorConnectionStatus status) async {
|
||||||
|
if (status == TorConnectionStatus.connecting) {
|
||||||
|
await disconnectFromNode();
|
||||||
|
}
|
||||||
|
if (status == TorConnectionStatus.connected) {
|
||||||
|
await connectOrDisconnectNodeToProxy(connect: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool torStarted = false;
|
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
|
@action
|
||||||
Future<void> startTor() async {
|
Future<void> startTor() async {
|
||||||
try {
|
try {
|
||||||
torConnectionStatus = TorConnectionStatus.connecting;
|
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) {
|
if (!torStarted) {
|
||||||
torStarted = true;
|
torStarted = true;
|
||||||
torInstance = await Tor.init();
|
torInstance = await Tor.init();
|
||||||
|
|
Loading…
Reference in a new issue