move the usage of rpvView to state

pull/2/head
fuwa 4 years ago
parent 1c83af1127
commit ee90f3765f

@ -26,7 +26,6 @@ import 'package:http/http.dart' as http;
import 'package:flutter/foundation.dart';
import '../../config.dart' as config;
import 'rpcView.dart' as rpcView;
import '../../helper.dart';
import '../../logging.dart';
@ -93,7 +92,7 @@ Future<http.Response> getInfo() => rpc('get_info');
Future<Map<String, dynamic>> getInfoSimple() async {
final _getInfo = await rpc('get_info').then(asMap);
return cleanKey(rpcView.getInfoView(_getInfo));
return _getInfo;
}
Future<String> getInfoString() => rpcString('get_info');
@ -105,7 +104,7 @@ Future<int> outgoingConnectionsCount() =>
Future<int> incomingConnectionsCount() =>
rpc('get_info', field: 'incoming_connections_count').then(asInt);
Future<List<dynamic>> getConnectionsSimple() async {
Future<List<Map<String, dynamic>>> getConnectionsSimple() async {
final _connections = await rpc('get_connections', field: 'connections').then(asJsonArray);
const minActiveTime = 8;
@ -120,7 +119,7 @@ Future<List<dynamic>> getConnectionsSimple() async {
}
);
return _sortedConn.map(rpcView.getConnectionView).toList();
return _sortedConn.toList();
}

@ -30,7 +30,6 @@ import 'package:intl/intl.dart';
import '../../config.dart' as config;
import '../../helper.dart';
import '../../logging.dart';
import 'rpc2View.dart' as rpc2View;
Future<http.Response> rpc2(final String method) async {
final url = 'http://${config.host}:${config.c.port}/${method}';
@ -101,6 +100,6 @@ Future<List<dynamic>> getTransactionPoolSimple() async {
}
);
return _decodedPool.map(rpc2View.txView).map(cleanKey).toList();
return _decodedPool.toList();
}
}

@ -38,6 +38,7 @@ import 'config.dart' as config;
import 'logging.dart';
import 'helper.dart';
import 'controller/rpc/rpcView.dart' as rpcView;
import 'controller/rpc/rpc2View.dart' as rpc2View;
abstract class AppState {
T use<T>
@ -304,24 +305,22 @@ class SyncedState extends HookedState {
// log.finer('SyncedState: checkSync loop');
height = await rpc.height();
connected = await daemon.isConnected();
getInfo = await rpc.getInfoSimple();
final _getInfo = await rpc.getInfoSimple();
getInfo = cleanKey(rpcView.getInfoView(_getInfo));
getInfoCache = pretty(getInfo);
final _getConnections = await rpc.getConnectionsSimple();
final List<Map<String, dynamic>> _getConnections = await rpc.getConnectionsSimple();
getConnections = _getConnections
.map(rpcView.getConnectionView)
.map((x) => rpcView.simpleHeight(height, x))
.map(cleanKey)
.toList();
getConnectionsCache = pretty(getConnections);
// getTransactionPool = await rpc.getTransactionPoolString();
getTransactionPool = await rpc.getTransactionPoolSimple();
final List<Map<String, dynamic>> _getTransactionPool = await rpc.getTransactionPoolSimple();
getTransactionPool = _getTransactionPool.map(rpc2View.txView).map(cleanKey).toList();
getTransactionPoolCache = pretty(getTransactionPool);
// appendInput('help');
// log.fine('getTransactionPool: $getTransactionPool');
syncState();
}
}