mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
don't save failover epicbox server to hive if primary fails
just return the failover
This commit is contained in:
parent
937c1263e7
commit
63fbd003e2
1 changed files with 16 additions and 20 deletions
|
@ -1036,35 +1036,31 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
}
|
||||
|
||||
Future<String> getEpicBoxConfig() async {
|
||||
final storedConfig =
|
||||
String? storedConfig =
|
||||
await _secureStore.read(key: '${_walletId}_epicboxConfig');
|
||||
if (storedConfig != null) {
|
||||
final decoded = json.decode(storedConfig!);
|
||||
dynamic decoded = json.decode(storedConfig!);
|
||||
final domain = decoded["domain"] ?? "empty";
|
||||
if (domain != "empty") {
|
||||
//If we have the old invalid config - update
|
||||
//Before writing to secure storage,ensure Epicbox is up
|
||||
|
||||
String defaultConfig = DefaultNodes.defaultEpicBoxConfig;
|
||||
final decoded = json.decode(defaultConfig);
|
||||
//If we have the old invalid config, use the new default one
|
||||
storedConfig = DefaultNodes.defaultEpicBoxConfig;
|
||||
decoded = json.decode(storedConfig);
|
||||
}
|
||||
//Check default Epicbox is up before returning it
|
||||
bool isEpicboxConnected = await testEpicboxServer(
|
||||
decoded["epicbox_domain"] as String,
|
||||
decoded["epicbox_port"] as int);
|
||||
decoded["epicbox_domain"] as String, decoded["epicbox_port"] as int);
|
||||
|
||||
if (!isEpicboxConnected) {
|
||||
//Default Epicbox is not connected, Defaulting to Europe
|
||||
defaultConfig = DefaultNodes.epicBoxConfigEUR;
|
||||
storedConfig = json.encode(DefaultNodes.epicBoxConfigEUR);
|
||||
// TODO test this connection before returning it, iterating through the list of default Epic Box servers
|
||||
}
|
||||
|
||||
await _secureStore.write(
|
||||
key: '${_walletId}_epicboxConfig', value: defaultConfig);
|
||||
}
|
||||
|
||||
return await _secureStore.read(key: '${_walletId}_epicboxConfig') ??
|
||||
DefaultNodes.defaultEpicBoxConfig;
|
||||
}
|
||||
return storedConfig;
|
||||
} else {
|
||||
return DefaultNodes.defaultEpicBoxConfig;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getRealConfig() async {
|
||||
String? config = await _secureStore.read(key: '${_walletId}_config');
|
||||
|
|
Loading…
Reference in a new issue