apply hashLengh to info

This commit is contained in:
fuwa
2019-07-24 14:39:54 +00:00
parent 2891890ff5
commit cd460f6053
4 changed files with 23 additions and 10 deletions
+16 -1
View File
@@ -86,6 +86,21 @@ Future<dynamic> height() => rpc('sync_info', field: 'height');
Future<http.Response> getInfo() => rpc('get_info');
Future<Map<String, dynamic>> getInfoSimple() async {
final Map<String, dynamic> _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<String> getInfoString() => rpcString('get_info');
Future<dynamic> offline() => rpc('get_info', field: 'offline');
@@ -112,7 +127,7 @@ Future<List<dynamic>> 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);
}
+1 -1
View File
@@ -100,7 +100,7 @@ Future<List<dynamic>> 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);
}
+2 -2
View File
@@ -199,7 +199,7 @@ class SyncedState extends HookedState {
Stream<String> processOutput;
bool synced = true;
bool connected = true;
String getInfo = 'getInfo';
Map<String, dynamic> getInfo = {};
String syncInfo = 'syncInfo';
List<dynamic> getConnections = [];
List<dynamic> 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();
+4 -6
View File
@@ -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 (