diff --git a/cyberwow/lib/controller/rpc/rpc.dart b/cyberwow/lib/controller/rpc/rpc.dart index 3f9e86c..1c43a9a 100644 --- a/cyberwow/lib/controller/rpc/rpc.dart +++ b/cyberwow/lib/controller/rpc/rpc.dart @@ -86,6 +86,21 @@ Future height() => rpc('sync_info', field: 'height'); Future getInfo() => rpc('get_info'); + +Future> getInfoSimple() async { + final Map _getInfo = await rpc('get_info'); + return _getInfo.map + ( + (k, v) { + if (k == 'top_block_hash') { + return MapEntry(k, v.substring(0, config.hashLength) + '...'); + } else { + return MapEntry(k, v); + } + } + ); +} + Future getInfoString() => rpcString('get_info'); Future offline() => rpc('get_info', field: 'offline'); @@ -112,7 +127,7 @@ Future> getConnectionsSimple() async { ( (k, v) { if (k == 'connection_id') { - return MapEntry(k, v.substring(0, 12) + '...'); + return MapEntry(k, v.substring(0, config.hashLength) + '...'); } else { return MapEntry(k, v); } diff --git a/cyberwow/lib/controller/rpc/rpc2.dart b/cyberwow/lib/controller/rpc/rpc2.dart index 8e4cac5..312db2b 100644 --- a/cyberwow/lib/controller/rpc/rpc2.dart +++ b/cyberwow/lib/controller/rpc/rpc2.dart @@ -100,7 +100,7 @@ Future> getTransactionPoolSimple() async { ( (k, v) { if (k == 'id_hash') { - return MapEntry(k, v.substring(0, 12) + '...'); + return MapEntry(k, v.substring(0, config.hashLength) + '...'); } else { return MapEntry(k, v); } diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index 06e90d5..3afac4b 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -199,7 +199,7 @@ class SyncedState extends HookedState { Stream processOutput; bool synced = true; bool connected = true; - String getInfo = 'getInfo'; + Map getInfo = {}; String syncInfo = 'syncInfo'; List getConnections = []; List getTransactionPool = []; @@ -229,7 +229,7 @@ class SyncedState extends HookedState { // log.finer('SyncedState: checkSync loop'); height = await rpc.height(); connected = await daemon.isConnected(); - getInfo = await rpc.getInfoString(); + getInfo = await rpc.getInfoSimple(); // syncInfo = await rpc.syncInfoString(); getConnections = await rpc.getConnectionsSimple(); // getTransactionPool = await rpc.getTransactionPoolString(); diff --git a/cyberwow/lib/widget/synced.dart b/cyberwow/lib/widget/synced.dart index c324c49..aa3ea3d 100644 --- a/cyberwow/lib/widget/synced.dart +++ b/cyberwow/lib/widget/synced.dart @@ -91,7 +91,7 @@ Widget summary(SyncedState state) { ); } -Widget rpcView(String title, String body) { +Widget rpcView(String title, dynamic body) { return Container ( padding: const EdgeInsets.all(10.0), @@ -137,7 +137,7 @@ Widget rpcView(String title, String body) { ), Text ( - body, + pretty(body), style: TextStyle ( fontFamily: 'RobotoMono', @@ -156,11 +156,9 @@ Widget rpcView(String title, String body) { } Widget getInfo(SyncedState state) => rpcView('info', state.getInfo); -Widget getConnections(SyncedState state) => - rpcView('connections', pretty(state.getConnections)); +Widget getConnections(SyncedState state) => rpcView('connections', state.getConnections); Widget syncInfo(SyncedState state) => rpcView('sync info', state.syncInfo); -Widget getTransactionPool(SyncedState state) => - rpcView('tx pool', pretty(state.getTransactionPool)); +Widget getTransactionPool(SyncedState state) => rpcView('tx pool', state.getTransactionPool); Widget pageView (SyncedState state, PageController controller) { return PageView (