diff --git a/lib/globals.dart b/lib/globals.dart index 5110f28..3a1bfa3 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -12,7 +12,7 @@ File currentChestFile; WalletData defaultWallet; String appVersion; SharedPreferences prefs; -String endPointGVA; +List endPointGVA; int ramSys; // String cesiumPod = "https://g1.data.le-sou.org"; diff --git a/lib/main.dart b/lib/main.dart index 05d9d3a..e50220d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,13 +51,14 @@ Future main() async { // await HiveStore.open(path: '${appPath.path}/gqlCache'); // Get a valid GVA endpoint - endPointGVA = await _homeProvider.getValidEndpoint(); + //endPointGVA = await _homeProvider.getValidEndpoint(); + await _homeProvider.scanNetwork(); - if (endPointGVA == 'HS') { - _homeProvider.playSound('faché', 0.8); - } else { - _homeProvider.playSound('start', 0.2); - } + // if (endPointGVA == 'HS') { + // _homeProvider.playSound('faché', 0.8); + // } else { + // _homeProvider.playSound('start', 0.2); + // } if (kReleaseMode && enableSentry) { // CatcherOptions debugOptions = CatcherOptions(DialogReportMode(), [ @@ -96,13 +97,13 @@ Future main() async { class Gecko extends StatelessWidget { Gecko(this.randomEndpoint); - final String randomEndpoint; + final List randomEndpoint; @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); final _httpLink = HttpLink( - randomEndpoint, + randomEndpoint[0], ); final _client = ValueNotifier( diff --git a/lib/models/history.dart b/lib/models/history.dart index ff5dd77..1a91410 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -62,7 +62,7 @@ class HistoryProvider with ChangeNotifier { amount: double.parse(payAmount.text), txComment: payComment.text, dewif: dewif, - gvaEndpoint: endPointGVA, + gvaEndpoint: endPointGVA[0], secretCode: pinCode, recipient: pubkey); return "Success"; @@ -234,11 +234,12 @@ class HistoryProvider with ChangeNotifier { void snackNode(context) { if (isFirstBuild) { String _message; - if (endPointGVA == 'HS') { + if (endPointGVA.isEmpty) { _message = "Aucun noeud Duniter disponible, veuillez réessayer ultérieurement"; } else { - _message = "Vous êtes connecté au noeud\n${endPointGVA.split('/')[2]}"; + _message = + "Vous êtes connecté au noeud\n${endPointGVA[0].split('/')[2]}"; } final snackBar = SnackBar(content: Text(_message), duration: Duration(seconds: 2)); diff --git a/lib/models/home.dart b/lib/models/home.dart index 63fc715..b69bf5b 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -41,6 +41,19 @@ class HomeProvider with ChangeNotifier { return version + '+' + buildNumber; } + Future> scanNetwork() async { + // TODO: return 5 endpoints from current window + // - Request all bootstrap endpoints to get theres current bloc number and hash, and theres known endpoinds + // - Store them in the Map endpoints with all endpoints sorted by highest current bloc with + // - Request all endpoints known by the last slave, only theses we don't even know + // - Do it 3 times, and return 5 highest endpoints, only theses in the current window (exclude these with another hashs) + + var endpoints = Map(); + List currentWindow = []; + + return currentWindow; + } + Future getValidEndpoint() async { List _listEndpoints = await rootBundle .loadString('config/gva_endpoints.json')