From 9c4fb36e0459c6f795e713d6d99ec448509a5d15 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 26 Nov 2019 02:21:23 +0800 Subject: [PATCH] include in/out in pool --- cyberwow/lib/controller/rpc/rpc2.dart | 41 +++++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/cyberwow/lib/controller/rpc/rpc2.dart b/cyberwow/lib/controller/rpc/rpc2.dart index 0de457a..4ddb9a7 100644 --- a/cyberwow/lib/controller/rpc/rpc2.dart +++ b/cyberwow/lib/controller/rpc/rpc2.dart @@ -88,7 +88,7 @@ Future> getTransactionPoolSimple() async { const _remove = [ 'tx_blob', - 'tx_json', + // 'tx_json', 'last_failed_id_hash', 'max_used_block_id_hash', // fields not useful for noobs @@ -99,6 +99,8 @@ Future> getTransactionPoolSimple() async { 'do_not_relay', 'last_failed_height', 'max_used_block_height', + 'weight', + // 'blob_size', ]; return Map.fromIterable @@ -112,25 +114,40 @@ Future> getTransactionPoolSimple() async { ( (k, v) { if (k == 'id_hash') { - return MapEntry(k, v.substring(0, config.hashLength) + '...'); - } else if (k == 'blob_size') { - final formatter = NumberFormat.compact(); - return MapEntry(k, formatter.format(v) + 'B'); - } else if (k == 'weight') { - final formatter = NumberFormat.compact(); - return MapEntry(k, formatter.format(v)); - } else if (k == 'fee') { + return MapEntry('id', v.substring(0, config.hashLength) + '...'); + } + + else if (k == 'blob_size') { + return MapEntry('size', (v / 1024).toStringAsFixed(2) + ' kB'); + } + + else if (k == 'fee') { final formatter = NumberFormat.currency ( symbol: '', decimalDigits: 2, ); return MapEntry(k, formatter.format(v / pow(10, 11)) + ' ⍵'); - } else if (k == 'receive_time') { + } + + else if (k == 'receive_time') { final _dateTime = DateTime.fromMillisecondsSinceEpoch(v * 1000); final _dateFormat = DateFormat.yMd().add_jm() ; - return MapEntry(k, _dateFormat.format(_dateTime)); - } else { + return MapEntry('time', _dateFormat.format(_dateTime)); + } + + else if (k == 'tx_json') { + final _tx = json.decode(v); + final _out = + { + 'vin': _tx['vin'].length, + 'vout': _tx['vout'].length, + }; + final _outString = _out['vin'].toString() + '/' + _out['vout'].toString(); + return MapEntry('in/out', _outString); + } + + else { return MapEntry(k, v); } }