diff --git a/cyberwow/lib/controller/rpc/rpc.dart b/cyberwow/lib/controller/rpc/rpc.dart index 40f41d1..3f9e86c 100644 --- a/cyberwow/lib/controller/rpc/rpc.dart +++ b/cyberwow/lib/controller/rpc/rpc.dart @@ -45,18 +45,17 @@ Future rpcHTTP(String method) async { } ); - var response; try { - response = await http.post + final response = await http.post ( url, body: body ); + return response; } catch (e) { - // print(e); + log.warning(e); + return null; } - - return response; } Future rpc(String method, {String field}) async { diff --git a/cyberwow/lib/controller/rpc/rpc2.dart b/cyberwow/lib/controller/rpc/rpc2.dart index d1c7c3a..8e4cac5 100644 --- a/cyberwow/lib/controller/rpc/rpc2.dart +++ b/cyberwow/lib/controller/rpc/rpc2.dart @@ -32,17 +32,16 @@ import '../../logging.dart'; Future rpc2(String method) async { final url = 'http://${config.host}:${config.c.port}/${method}'; - var response; try { - response = await http.post + final response = await http.post ( url, ); + return response; } catch (e) { log.warning(e); + return null; } - - return response; } Future rpc2String(String method, {String field}) async { diff --git a/cyberwow/lib/controller/syncing.dart b/cyberwow/lib/controller/syncing.dart index 893fda1..5515d23 100644 --- a/cyberwow/lib/controller/syncing.dart +++ b/cyberwow/lib/controller/syncing.dart @@ -60,7 +60,7 @@ Stream runBinary (String name) async* { log.info('args: ' + args.toString()); final outputProcess = await Process.start(newPath, args); - await for (var line in outputProcess.stdout.transform(utf8.decoder)) { + await for (final line in outputProcess.stdout.transform(utf8.decoder)) { yield line; } diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index ff1a9b6..06e90d5 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -122,7 +122,7 @@ class LoadingState extends HookedState { Future load() async { log.fine("Loading next"); - await for (var line in loadingProgress) { + await for (final line in loadingProgress) { // append(line); log.info(line); } @@ -156,7 +156,7 @@ class SyncingState extends HookedState { log.fine("Syncing next"); Future printStdout() async { - await for (var line in processOutput) { + await for (final line in processOutput) { if (synced) break; log.finest('syncing: print stdout loop'); @@ -166,7 +166,7 @@ class SyncingState extends HookedState { } Future checkSync() async { - await for (var _null in refresh.pull(getNotification, 'syncingState')) { + await for (final _null in refresh.pull(getNotification, 'syncingState')) { log.finer('SyncingState: checkSync loop'); // here doc is wrong, targetHeight could match height when synced @@ -210,7 +210,7 @@ class SyncedState extends HookedState { log.fine("Synced next"); Future logStdout() async { - await for (var line in processOutput) { + await for (final line in processOutput) { if (!synced) break; // print('synced: print stdout loop'); stdout += line; @@ -221,7 +221,7 @@ class SyncedState extends HookedState { logStdout(); Future checkSync() async { - await for (var _null in refresh.pull(getNotification, 'syncedState')) { + await for (final _null in refresh.pull(getNotification, 'syncedState')) { if (await daemon.isNotSynced()) { synced = false; break; @@ -267,7 +267,7 @@ class ReSyncingState extends HookedState { log.fine("ReSyncing next"); Future printStdout() async { - await for (var line in processOutput) { + await for (final line in processOutput) { if (synced) break; // print('re-syncing: print stdout loop'); append(line); @@ -276,7 +276,7 @@ class ReSyncingState extends HookedState { } Future checkSync() async { - await for (var _null in refresh.pull(getNotification, 'ReSyncingState')) { + await for (final _null in refresh.pull(getNotification, 'ReSyncingState')) { if (await daemon.isSynced()) { synced = true;