mirror of
https://github.com/wownero/cyberwow.git
synced 2026-10-19 00:08:43 +02:00
use positive out peers as a conditional for syncing break
This commit is contained in:
@@ -111,3 +111,17 @@ Future<bool> offline() async {
|
||||
return responseBody["offline"];
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> outgoing_connections_count() async {
|
||||
var response = await getInfo();
|
||||
|
||||
if (response == null) return -1;
|
||||
|
||||
// print('Response status: ${response.statusCode}');
|
||||
if (response.statusCode != 200) {
|
||||
return -1;
|
||||
} else {
|
||||
final responseBody = json.decode(response.body)['result'];
|
||||
return responseBody["outgoing_connections_count"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ class SyncingState extends HookedState {
|
||||
// final _offline = await rpc.offline();
|
||||
// print('syncing: offline ${_offline}');
|
||||
|
||||
final bool initState = line.contains('Initializing core');
|
||||
if (initState)
|
||||
print('is init state');
|
||||
if (_targetHeight == 0 && (!initState) && _height > minimumHeight) break;
|
||||
final _out_peers = await rpc.outgoing_connections_count();
|
||||
// print('syncing: out_peers ${_out_peers}');
|
||||
|
||||
if (_targetHeight == 0 && _out_peers > 0) break;
|
||||
}
|
||||
|
||||
print('syncing: loop exit');
|
||||
|
||||
Reference in New Issue
Block a user