From 694bd75d610c5b00876981905721362216b93507 Mon Sep 17 00:00:00 2001 From: fuwa Date: Mon, 2 Dec 2019 18:04:28 +0800 Subject: [PATCH] store rpc results rather then views in state --- Makefile | 2 +- cyberwow/lib/state.dart | 20 +++++++++++--------- cyberwow/lib/widget/synced.dart | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index c7e35a9..b6c296b 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ watch: run: cd cyberwow && \ - flutter run --pid-file /tmp/flutter.pid + flutter run --release --pid-file /tmp/flutter.pid # clang -target aarch64-linux-android21 cyberwow/native/hello.c -o cyberwow/native/output/hello c: diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index 17e52c8..bb347d9 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -305,21 +305,23 @@ class SyncedState extends HookedState { // log.finer('SyncedState: checkSync loop'); height = await rpc.height(); connected = await daemon.isConnected(); - final _getInfo = await rpc.getInfoSimple(); - getInfo = cleanKey(rpcView.getInfoView(_getInfo)); - getInfoCache = pretty(getInfo); + getInfo = await rpc.getInfoSimple(); + final _getInfoView = cleanKey(rpcView.getInfoView(getInfo)); + getInfoCache = pretty(_getInfoView); - final List> _getConnections = await rpc.getConnectionsSimple(); - getConnections = _getConnections + getConnections = await rpc.getConnectionsSimple(); + final List> _getConnectionsView = + getConnections .map(rpcView.getConnectionView) .map((x) => rpcView.simpleHeight(height, x)) .map(cleanKey) .toList(); - getConnectionsCache = pretty(getConnections); + getConnectionsCache = pretty(_getConnectionsView); - final List> _getTransactionPool = await rpc.getTransactionPoolSimple(); - getTransactionPool = _getTransactionPool.map(rpc2View.txView).map(cleanKey).toList(); - getTransactionPoolCache = pretty(getTransactionPool); + getTransactionPool = await rpc.getTransactionPoolSimple(); + final List> _getTransactionPoolView = + getTransactionPool.map(rpc2View.txView).map(cleanKey).toList(); + getTransactionPoolCache = pretty(_getTransactionPoolView); syncState(); } diff --git a/cyberwow/lib/widget/synced.dart b/cyberwow/lib/widget/synced.dart index 6d68964..a6ba5e7 100644 --- a/cyberwow/lib/widget/synced.dart +++ b/cyberwow/lib/widget/synced.dart @@ -36,7 +36,7 @@ Widget summary(BuildContext context, SyncedState state) { final poolLength = state.getTransactionPool.length; final poolLengthNotice = poolLength > 1 ? '[${poolLength}] ' : ''; final txNotice = state.getTransactionPool.isEmpty ? - '' : poolLengthNotice + state.getTransactionPool.first['id '].substring(0, 6) + ' ...'; + '' : poolLengthNotice + state.getTransactionPool.first['id_hash'].substring(0, 6) + ' ...'; return Container (