diff --git a/lib/models/home.dart b/lib/models/home.dart index b69bf5b..9c0da8a 100644 --- a/lib/models/home.dart +++ b/lib/models/home.dart @@ -1,3 +1,4 @@ +import 'dart:collection'; import 'dart:convert'; import 'dart:io'; import 'dart:math'; @@ -42,13 +43,23 @@ class HomeProvider with ChangeNotifier { } 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) + // TODO: return all known endpoints from current window + // - Request all bootstrap endpoints to get theres current bloc number and hash (blockstamps), and theres known endpoinds + // - Store them in an ordered Map (SplayTreeMap>) (the HashSet is a endpoint) + // - Request 5 randoms endpoints known by the last slave, only theses we don't even know + // - Do it 3 times + // - We iterate the Map to determinat the consensus with for loop, intinital consensus variable to null + // - if consensus == null -> if blockstamp > (1/3 known endpoints) -> consensus = blockstamp + // - elif blockstamp.number == consensus.number && blockstamp.endpointNumbers > consensus.endpointNumbers -> consensus = blockstamp + // - else break; + // - return map.get(key: consensus).toList + + var endpoints = SplayTreeMap>(); + + for (String endpoint in endPointGVA) { + // gva request + } - var endpoints = Map(); List currentWindow = []; return currentWindow;