From 14b1d83672473c672098375df2c4812c21c574bd Mon Sep 17 00:00:00 2001 From: fuwa Date: Sun, 29 Mar 2020 10:59:44 +0800 Subject: [PATCH 01/10] increase terminal buffer size --- cyberwow/lib/config.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cyberwow/lib/config.dart b/cyberwow/lib/config.dart index 49635ab..480758e 100644 --- a/cyberwow/lib/config.dart +++ b/cyberwow/lib/config.dart @@ -35,6 +35,6 @@ const emuHost = '192.168.10.100'; const host = isEmu ? emuHost : '127.0.0.1'; -const stdoutLineBufferSize = 100; +const stdoutLineBufferSize = 200; const bannerShownKey = 'banner-shown'; From 48b87fa11ffb1721aaa6f31a98e08e4fc776ec91 Mon Sep 17 00:00:00 2001 From: fuwa Date: Sun, 29 Mar 2020 13:06:18 +0800 Subject: [PATCH 02/10] log to /dev/null --- cyberwow/lib/config/cyberwow.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/cyberwow/lib/config/cyberwow.dart b/cyberwow/lib/config/cyberwow.dart index d72f4c7..00a92a7 100644 --- a/cyberwow/lib/config/cyberwow.dart +++ b/cyberwow/lib/config/cyberwow.dart @@ -95,6 +95,7 @@ final config = CryptoConfig '--no-igd', '--check-updates=disabled', '--disable-dns-checkpoints', + '--log-file=/dev/null', '--max-log-file-size=0', '--p2p-use-ipv6', ], From 03cbfc78f3bd13969d87487ac306f71861d4cd12 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 31 Mar 2020 20:51:50 +0800 Subject: [PATCH 03/10] use jdk13 --- etc/nix/shell.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/nix/shell.nix b/etc/nix/shell.nix index 725acd7..cbd09b3 100644 --- a/etc/nix/shell.nix +++ b/etc/nix/shell.nix @@ -53,7 +53,7 @@ with nixpkgs; # openjdk # jetbrains.jdk # zulu - jdk12 + jdk13 # dart_dev gnumake gcc From 54ff3cf83ce65368af1bdc4eedf2f253e6be3e78 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 31 Mar 2020 20:51:24 +0800 Subject: [PATCH 04/10] rework resyncing state --- cyberwow/lib/widget/resyncing.dart | 80 ++++++++++++++++-------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/cyberwow/lib/widget/resyncing.dart b/cyberwow/lib/widget/resyncing.dart index dc6f20a..78ab660 100644 --- a/cyberwow/lib/widget/resyncing.dart +++ b/cyberwow/lib/widget/resyncing.dart @@ -25,49 +25,53 @@ import '../state.dart'; import '../config.dart' as config; Widget build(BuildContext context, ReSyncingState state) { + final progressWidget = + [ + Spacer + ( + flex: 3, + ), + LinearProgressIndicator(), + Spacer + ( + flex: 2, + ), + Expanded + ( + flex: 5, + child: Text + ( + state.stdout.last, + style: Theme.of(context).textTheme.body1, + ) + ), + ]; + return Scaffold ( - // appBar: AppBar - // ( - // // title: Text(widget.title), - // title: Text('CyberWOW'), - // ), body: Container ( - // padding: const EdgeInsets.all(10.0), - child: Align + padding: const EdgeInsets.all(10.0), + child: Column ( - alignment: Alignment.topLeft, - child: Column - ( - mainAxisAlignment: MainAxisAlignment.center, - children: - [ - Spacer - ( - flex: 1, - ), - Expanded - ( - flex: 1, - child: SingleChildScrollView - ( - scrollDirection: Axis.vertical, - reverse: true, - child: Text - ( - state.stdout.last, - style: Theme.of(context).textTheme.body1, - ) - ) - ), - Spacer - ( - flex: 1, - ), - ], - ), + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: + [ + Spacer + ( + flex: 10, + ), + ] + + progressWidget + + [ + Spacer + ( + flex: 10, + ), + ] ), - ), + ) ); } + From 597b9bdb847ff91d0a186d6a130713fb3d37c5c1 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 31 Mar 2020 23:51:28 +0800 Subject: [PATCH 05/10] upgrade gradle to 6.3 for jdk13 --- cyberwow/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cyberwow/android/gradle/wrapper/gradle-wrapper.properties b/cyberwow/android/gradle/wrapper/gradle-wrapper.properties index e5b2f0f..343caf5 100644 --- a/cyberwow/android/gradle/wrapper/gradle-wrapper.properties +++ b/cyberwow/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip From 4e16219f6145125d3769d181206edd658aaa6ba8 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 31 Mar 2020 23:52:42 +0800 Subject: [PATCH 06/10] fix nullable intent --- .../app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cyberwow/android/app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt b/cyberwow/android/app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt index 1a02d9d..fc1356f 100644 --- a/cyberwow/android/app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt +++ b/cyberwow/android/app/src/main/kotlin/org/wownero/cyberwow/MainActivity.kt @@ -44,9 +44,9 @@ class MainActivity: FlutterActivity() { } internal fun handleSendText(intent:Intent) { - val text:String = intent.getStringExtra(Intent.EXTRA_TEXT) + val text:String? = intent.getStringExtra(Intent.EXTRA_TEXT) if (initialIntentSet == false) { - initialIntentText = text + initialIntentText = text ?: ""; } } From c6d6f2984fdec036c9e846c12585dbc173c3a1bc Mon Sep 17 00:00:00 2001 From: fuwa Date: Sat, 4 Apr 2020 18:52:37 +0800 Subject: [PATCH 07/10] fix ui lag caused by large tx pool --- cyberwow/lib/config.dart | 2 + cyberwow/lib/logic/sensor/rpc/rpc2.dart | 28 ++++++++++-- cyberwow/lib/logic/view/rpc/rpc2.dart | 58 ++++++++++--------------- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/cyberwow/lib/config.dart b/cyberwow/lib/config.dart index 480758e..1910855 100644 --- a/cyberwow/lib/config.dart +++ b/cyberwow/lib/config.dart @@ -38,3 +38,5 @@ const host = isEmu ? emuHost : '127.0.0.1'; const stdoutLineBufferSize = 200; const bannerShownKey = 'banner-shown'; +const int maxPoolTxSize = 5000; + diff --git a/cyberwow/lib/logic/sensor/rpc/rpc2.dart b/cyberwow/lib/logic/sensor/rpc/rpc2.dart index 59cfd23..5f21320 100644 --- a/cyberwow/lib/logic/sensor/rpc/rpc2.dart +++ b/cyberwow/lib/logic/sensor/rpc/rpc2.dart @@ -27,11 +27,14 @@ import 'package:http/http.dart' as http; import 'package:flutter/foundation.dart'; import '../../../helper.dart'; +import '../../../config.dart' as config; import '../../../logging.dart'; import '../../interface/rpc/rpc2.dart' as rpc2; Future getTransactionPool() async => rpc2.rpc2('get_transaction_pool'); +Map txInOutCache = {}; + Future>> getTransactionPoolSimple() async { final response = await getTransactionPool(); @@ -57,12 +60,31 @@ Future>> getTransactionPoolSimple() async { final _decodedPool = await Stream.fromIterable(_sortedPool).asyncMap ( (x) async { - final String _tx_json = x['tx_json']; - final _tx_json_decoded = await compute(jsonDecode, _tx_json); + if (txInOutCache.length > config.maxPoolTxSize) { + txInOutCache = {}; + } + + final _txid = x['id_hash']; + + if (txInOutCache[_txid] == null) { + final String _tx_json = x['tx_json']; + final _tx_json_decoded = await compute(jsonDecode, _tx_json); + + final _inOut = + { + 'vin': _tx_json_decoded['vin'].length, + 'vout': _tx_json_decoded['vout'].length, + }; + + final _inOutString = _inOut['vin'].toString() + '/' + _inOut['vout'].toString(); + + txInOutCache[_txid] = _inOutString; + log.fine('cached tx_json in pool for: ${_txid}'); + } return { ...x, - ...{'tx_decoded': _tx_json_decoded}, + ...{'i/o': txInOutCache[_txid]}, }; } ); diff --git a/cyberwow/lib/logic/view/rpc/rpc2.dart b/cyberwow/lib/logic/view/rpc/rpc2.dart index 4d8d7af..34c2a06 100644 --- a/cyberwow/lib/logic/view/rpc/rpc2.dart +++ b/cyberwow/lib/logic/view/rpc/rpc2.dart @@ -53,45 +53,33 @@ Map txView(Map x) { final _formattedTx = _filteredTx.map ( (k, v) { - if (k == 'id_hash') { - return MapEntry('id', trimHash(v)); + switch (k) { + case 'id_hash': + return MapEntry('id', trimHash(v)); + case 'blob_size': + return MapEntry('size', (v / 1024).toStringAsFixed(2) + ' kB'); + case 'fee': { + final formatter = NumberFormat.currency + ( + symbol: '', + decimalDigits: 2, + ); + return MapEntry(k, formatter.format(v / pow(10, 11)) + ' ⍵'); + } + case 'receive_time': { + final _receive_time = DateTime.fromMillisecondsSinceEpoch(v * 1000); + final _diff = DateTime.now().difference(_receive_time); + + format(Duration d) => d.toString().split('.').first.padLeft(8, "0"); + return MapEntry('age', format(_diff)); + } + default: + return MapEntry(k, v); } + } - 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') { - final _receive_time = DateTime.fromMillisecondsSinceEpoch(v * 1000); - final _diff = DateTime.now().difference(_receive_time); - - format(Duration d) => d.toString().split('.').first.padLeft(8, "0"); - return MapEntry('age', format(_diff)); - } - else if (k == 'tx_decoded') { - final _out = - { - 'vin': v['vin'].length, - 'vout': v['vout'].length, - }; - final _outString = _out['vin'].toString() + '/' + _out['vout'].toString(); - return MapEntry('i/o', _outString); - } - else { - return MapEntry(k, v); - } - } ); final List keys = From b02b5f8bb3eeafd123e15b7824ddfca79a8f2f6b Mon Sep 17 00:00:00 2001 From: fuwa Date: Sat, 4 Apr 2020 22:47:29 +0800 Subject: [PATCH 08/10] useless clean up using switch --- cyberwow/lib/logic/view/rpc/rpc.dart | 110 ++++++++++++++------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/cyberwow/lib/logic/view/rpc/rpc.dart b/cyberwow/lib/logic/view/rpc/rpc.dart index 7fc0427..56e6a59 100644 --- a/cyberwow/lib/logic/view/rpc/rpc.dart +++ b/cyberwow/lib/logic/view/rpc/rpc.dart @@ -58,29 +58,30 @@ Map getConnectionView(Map x) { final _formattedConn = _filteredConn.map ( (k, v) { - if (k == 'connection_id') { - return MapEntry(k, trimHash(v)); - } - - const speedField = - [ - 'avg_download', - 'avg_upload', - 'current_download', - 'current_upload', - ]; - if (speedField.contains(k)) { - return MapEntry(k, '${v} kB/s'); - } - - else if (k == 'live_time') { - final _duration = Duration(seconds: v); - format(Duration d) => d.toString().split('.').first.padLeft(8, "0"); - return MapEntry(k, format(_duration)); - } - - else { - return MapEntry(k, v); + switch (k) { + case 'connection_id': { + return MapEntry(k, trimHash(v)); + } + case 'live_time': { + final _duration = Duration(seconds: v); + format(Duration d) => d.toString().split('.').first.padLeft(8, "0"); + return MapEntry(k, format(_duration)); + } + default: { + const speedField = + [ + 'avg_download', + 'avg_upload', + 'current_download', + 'current_upload', + ]; + if (speedField.contains(k)) { + return MapEntry(k, '${v} kB/s'); + } + else { + return MapEntry(k, v); + } + } } } ); @@ -171,38 +172,39 @@ Map getInfoView(Map x) { final _formattedInfo = _ammendedInfo.map ( (k, v) { - if (k == 'top_block_hash') { - return MapEntry(k, trimHash(v)); - } - - const sizeField = - [ - 'block_size_limit', - 'block_size_median', - 'block_weight_limit', - 'block_weight_median', - 'difficulty', - 'tx_count', - 'cumulative_difficulty', - 'free_space', - 'database_size', - 'hash_rate', - ]; - if (sizeField.contains(k)) { - final formatter = NumberFormat.compact(); - return MapEntry(k, formatter.format(v)); - } - - else if (k == 'start_time') { - final _receive_time = DateTime.fromMillisecondsSinceEpoch(v * 1000); - final _diff = DateTime.now().difference(_receive_time); - - format(Duration d) => d.toString().split('.').first.padLeft(8, "0"); - return MapEntry('uptime', format(_diff)); - } + switch (k) { + case 'top_block_hash': { + return MapEntry(k, trimHash(v)); + } + case 'start_time': { + final _receive_time = DateTime.fromMillisecondsSinceEpoch(v * 1000); + final _diff = DateTime.now().difference(_receive_time); - else { - return MapEntry(k, v); + format(Duration d) => d.toString().split('.').first.padLeft(8, "0"); + return MapEntry('uptime', format(_diff)); + } + default: { + const sizeField = + [ + 'block_size_limit', + 'block_size_median', + 'block_weight_limit', + 'block_weight_median', + 'difficulty', + 'tx_count', + 'cumulative_difficulty', + 'free_space', + 'database_size', + 'hash_rate', + ]; + if (sizeField.contains(k)) { + final formatter = NumberFormat.compact(); + return MapEntry(k, formatter.format(v)); + } + else { + return MapEntry(k, v); + } + } } } ); From 62edd0c4f9c729df08dd277ef7a76fa3dd11a053 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 7 Apr 2020 05:20:48 +0800 Subject: [PATCH 09/10] update openssl --- etc/scripts/build-external-libs/openssl/build.sh | 2 +- etc/scripts/build-external-libs/openssl/fetch.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/scripts/build-external-libs/openssl/build.sh b/etc/scripts/build-external-libs/openssl/build.sh index 9655dc9..96945d9 100755 --- a/etc/scripts/build-external-libs/openssl/build.sh +++ b/etc/scripts/build-external-libs/openssl/build.sh @@ -37,7 +37,7 @@ build_root=$BUILD_ROOT src_root=$BUILD_ROOT_SRC name=openssl -version=1.1.1d +version=1.1.1f cd $src_root/${name}-${version} diff --git a/etc/scripts/build-external-libs/openssl/fetch.sh b/etc/scripts/build-external-libs/openssl/fetch.sh index b480c7a..2fb1088 100755 --- a/etc/scripts/build-external-libs/openssl/fetch.sh +++ b/etc/scripts/build-external-libs/openssl/fetch.sh @@ -36,8 +36,8 @@ source etc/scripts/build-external-libs/env.sh cd $BUILD_ROOT_SRC name=openssl -version=1.1.1d -hash=1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2 +version=1.1.1f +hash=186c6bfe6ecfba7a5b48c47f8a1673d0f3b0e5ba2e25602dd23b629975da3f35 rm -rf ${name}-${version} From cff517b6b092494d7adaeb1296300725c7acf49a Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 7 Apr 2020 20:53:45 +0800 Subject: [PATCH 10/10] up version --- cyberwow/android/app/build.gradle | 4 ++-- cyberwow/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cyberwow/android/app/build.gradle b/cyberwow/android/app/build.gradle index 26a5cfe..01d428e 100644 --- a/cyberwow/android/app/build.gradle +++ b/cyberwow/android/app/build.gradle @@ -41,8 +41,8 @@ android { applicationId "org.wownero.cyberwow" minSdkVersion 26 targetSdkVersion 29 - versionCode 24 - versionName "0.7.0.0-k" + versionCode 25 + versionName "0.7.0.0-l" } if(project.hasProperty("RELEASE_STORE_FILE")) { diff --git a/cyberwow/pubspec.yaml b/cyberwow/pubspec.yaml index 4106a47..d2c5165 100644 --- a/cyberwow/pubspec.yaml +++ b/cyberwow/pubspec.yaml @@ -1,7 +1,7 @@ name: cyberwow description: A new Flutter project. -version: 0.7.0+24 +version: 0.7.0+25 environment: sdk: ">=2.1.0 <3.0.0"