async decode tx_json

pull/2/head
fuwa 5 years ago
parent 905ea67b51
commit 0f1ce0e00a

@ -82,9 +82,9 @@ Future<List<dynamic>> getTransactionPoolSimple() async {
return []; return [];
} }
else { else {
return result.map return Stream.fromIterable(result).asyncMap
( (
(x) { (x) async {
const _remove = const _remove =
[ [
'tx_blob', 'tx_blob',
@ -103,14 +103,20 @@ Future<List<dynamic>> getTransactionPoolSimple() async {
// 'blob_size', // 'blob_size',
]; ];
final _tx = Map.fromIterable final _filteredTx = x..removeWhere
( (
x.keys.where (k,v) => _remove.contains(k)
( );
(k) => !_remove.contains(k)
), final String _tx_json = _filteredTx['tx_json'];
value: (k) => x[k], final _tx_json_decoded = await compute(jsonDecode, _tx_json);
).map
final _decodedTx = {
..._filteredTx,
...{'tx_decoded': _tx_json_decoded},
};
final _tx = _filteredTx.map
( (
(k, v) { (k, v) {
if (k == 'id_hash') { if (k == 'id_hash') {
@ -136,12 +142,11 @@ Future<List<dynamic>> getTransactionPoolSimple() async {
return MapEntry('time', _dateFormat.format(_dateTime)); return MapEntry('time', _dateFormat.format(_dateTime));
} }
else if (k == 'tx_json') { else if (k == 'tx_json_decoded') {
final _tx = json.decode(v);
final _out = final _out =
{ {
'vin': _tx['vin'].length, 'vin': v['vin'].length,
'vout': _tx['vout'].length, 'vout': v['vout'].length,
}; };
final _outString = _out['vin'].toString() + '/' + _out['vout'].toString(); final _outString = _out['vin'].toString() + '/' + _out['vout'].toString();
return MapEntry('in/out', _outString); return MapEntry('in/out', _outString);