diff --git a/cyberwow/lib/controller/helper.dart b/cyberwow/lib/controller/helper.dart
index bc2d12e..b1fb060 100644
--- a/cyberwow/lib/controller/helper.dart
+++ b/cyberwow/lib/controller/helper.dart
@@ -21,8 +21,11 @@ along with CyberWOW. If not, see .
import 'dart:async';
import 'dart:io';
+import 'dart:convert';
import 'package:path_provider/path_provider.dart';
+import 'package:http/http.dart' as http;
+import 'package:flutter/foundation.dart';
Future getBinaryPath(String name) async {
final tmpDir = await getTemporaryDirectory();
@@ -33,3 +36,37 @@ Future binaryExists(String name) async {
final binPath = await getBinaryPath(name);
return new File(binPath).exists();
}
+
+Future targetHeight() async {
+ var url = '';
+ if (kReleaseMode) {
+ url = 'http://127.0.0.1:34568/json_rpc';
+ } else {
+ url = 'http://192.168.10.100:34568/json_rpc';
+ }
+
+ final body = json.encode
+ (
+ {
+ 'jsonrpc': '2.0',
+ 'id': '0',
+ 'method': 'sync_info',
+ }
+ );
+
+ var response = await http.post
+ ( url,
+ body: body
+ );
+
+ print('Response status: ${response.statusCode}');
+ if (response.statusCode != 200) {
+ return -1;
+ } else {
+ final responseBody = json.decode(response.body)['result'];
+ final targetHeight = responseBody["target_height"];
+ // print('height: ${responseBody["height"]}');
+
+ return targetHeight;
+ }
+}