Change single endpoint to List in main; create scanNetwork method, with todo for all process
This commit is contained in:
parent
87c8ccef46
commit
c3bc3c9319
|
@ -12,7 +12,7 @@ File currentChestFile;
|
|||
WalletData defaultWallet;
|
||||
String appVersion;
|
||||
SharedPreferences prefs;
|
||||
String endPointGVA;
|
||||
List<String> endPointGVA;
|
||||
int ramSys;
|
||||
|
||||
// String cesiumPod = "https://g1.data.le-sou.org";
|
||||
|
|
|
@ -51,13 +51,14 @@ Future<void> 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<void> main() async {
|
|||
|
||||
class Gecko extends StatelessWidget {
|
||||
Gecko(this.randomEndpoint);
|
||||
final String randomEndpoint;
|
||||
final List<String> randomEndpoint;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
final _httpLink = HttpLink(
|
||||
randomEndpoint,
|
||||
randomEndpoint[0],
|
||||
);
|
||||
|
||||
final _client = ValueNotifier(
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -41,6 +41,19 @@ class HomeProvider with ChangeNotifier {
|
|||
return version + '+' + buildNumber;
|
||||
}
|
||||
|
||||
Future<List<String>> 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<String> currentWindow = [];
|
||||
|
||||
return currentWindow;
|
||||
}
|
||||
|
||||
Future<String> getValidEndpoint() async {
|
||||
List _listEndpoints = await rootBundle
|
||||
.loadString('config/gva_endpoints.json')
|
||||
|
|
Loading…
Reference in New Issue