mirror of
https://github.com/wownero/cyberwow.git
synced 2026-12-03 13:43:59 +01:00
simplify height in peers
This commit is contained in:
@@ -25,7 +25,7 @@ import 'package:intl/intl.dart';
|
||||
|
||||
import '../../config.dart' as config;
|
||||
|
||||
Map<String, dynamic> rpcTxView(x) {
|
||||
Map<String, dynamic> rpcTxView(Map<String, dynamic> x) {
|
||||
const _remove =
|
||||
[
|
||||
'tx_blob',
|
||||
@@ -105,7 +105,7 @@ Map<String, dynamic> rpcTxView(x) {
|
||||
.toList();
|
||||
|
||||
final _sortedTx = {
|
||||
for (var k in keys) k: _tx[k]
|
||||
for (final k in keys) k: _tx[k]
|
||||
};
|
||||
|
||||
return _sortedTx;
|
||||
|
||||
@@ -98,7 +98,7 @@ Map<String, dynamic> rpcPeerView(Map<String, dynamic> x) {
|
||||
.toList();
|
||||
|
||||
final _sortedConn = {
|
||||
for (var k in keys) k: _conn[k]
|
||||
for (final k in keys) k: _conn[k]
|
||||
};
|
||||
|
||||
final _cleanupConn = _sortedConn..removeWhere
|
||||
@@ -109,3 +109,26 @@ Map<String, dynamic> rpcPeerView(Map<String, dynamic> x) {
|
||||
return _cleanupConn;
|
||||
}
|
||||
|
||||
Map<String, dynamic> simpleHeight(int height, Map<String, dynamic> x) {
|
||||
return x.map
|
||||
(
|
||||
(k, v) {
|
||||
if (k == 'height') {
|
||||
if (v < height) {
|
||||
return MapEntry('height', '- ${height - v}');
|
||||
}
|
||||
|
||||
else if (v == height) {
|
||||
return MapEntry('height', '✓');
|
||||
}
|
||||
|
||||
else {
|
||||
return MapEntry('height', '+ ${v - height}');
|
||||
}
|
||||
}
|
||||
else {
|
||||
return MapEntry(k, v);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import 'controller/daemon.dart' as daemon;
|
||||
import 'controller/refresh.dart' as refresh;
|
||||
import 'config.dart' as config;
|
||||
import 'logging.dart';
|
||||
import 'controller/rpc/rpcView.dart';
|
||||
|
||||
abstract class AppState {
|
||||
T use<T>
|
||||
@@ -236,8 +237,8 @@ class SyncedState extends HookedState {
|
||||
bool userExit = false;
|
||||
bool connected = true;
|
||||
Map<String, dynamic> getInfo = {};
|
||||
List<dynamic> getConnections = [];
|
||||
List<dynamic> getTransactionPool = [];
|
||||
List<Map<String, dynamic>> getConnections = [];
|
||||
List<Map<String, dynamic>> getTransactionPool = [];
|
||||
int pageIndex;
|
||||
String syncInfo = 'syncInfo';
|
||||
PageController pageController;
|
||||
@@ -299,7 +300,9 @@ class SyncedState extends HookedState {
|
||||
height = await rpc.height();
|
||||
connected = await daemon.isConnected();
|
||||
getInfo = await rpc.getInfoSimple();
|
||||
getConnections = await rpc.getConnectionsSimple();
|
||||
final _getConnections = await rpc.getConnectionsSimple();
|
||||
getConnections = _getConnections.map((x) => simpleHeight(height, x)).toList();
|
||||
|
||||
// getTransactionPool = await rpc.getTransactionPoolString();
|
||||
|
||||
getTransactionPool = await rpc.getTransactionPoolSimple();
|
||||
|
||||
Reference in New Issue
Block a user