From 49a1215ca6e614fc9b9bc86cd3d4ce680557b0ad Mon Sep 17 00:00:00 2001 From: fuwa Date: Mon, 23 Dec 2019 09:17:02 +0800 Subject: [PATCH] move hash block length to config --- cyberwow/lib/config.dart | 1 - cyberwow/lib/config/cyberwow.dart | 1 + cyberwow/lib/config/prototype.dart | 2 ++ cyberwow/lib/helper.dart | 9 ++++----- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cyberwow/lib/config.dart b/cyberwow/lib/config.dart index c6ccbf1..19e9ab1 100644 --- a/cyberwow/lib/config.dart +++ b/cyberwow/lib/config.dart @@ -35,6 +35,5 @@ const emuHost = '192.168.10.100'; const host = isEmu ? emuHost : '127.0.0.1'; -const int hashViewBlock = 6; const stdoutLineBufferSize = 100; diff --git a/cyberwow/lib/config/cyberwow.dart b/cyberwow/lib/config/cyberwow.dart index 15dd463..59ae822 100644 --- a/cyberwow/lib/config/cyberwow.dart +++ b/cyberwow/lib/config/cyberwow.dart @@ -93,4 +93,5 @@ final config = CryptoConfig '--block-sync-size=5', ], '[1337@cyberwow]: ', + 6, ); diff --git a/cyberwow/lib/config/prototype.dart b/cyberwow/lib/config/prototype.dart index e67791d..8e4ab61 100644 --- a/cyberwow/lib/config/prototype.dart +++ b/cyberwow/lib/config/prototype.dart @@ -30,6 +30,7 @@ class CryptoConfig { final int port; final List extraArgs; final String promptString; + final int hashViewBlockLength; const CryptoConfig ( this.outputBin, @@ -40,5 +41,6 @@ class CryptoConfig { this.port, this.extraArgs, this.promptString, + this.hashViewBlockLength, ); } diff --git a/cyberwow/lib/helper.dart b/cyberwow/lib/helper.dart index ff6265b..02881c0 100644 --- a/cyberwow/lib/helper.dart +++ b/cyberwow/lib/helper.dart @@ -32,11 +32,10 @@ String pretty(dynamic x) { ; } -String trimHash(String x) => -x.substring(0, config.hashViewBlock) -+ '-' -+ x.substring(config.hashViewBlock, config.hashViewBlock * 2) -+ ' ...'; +String trimHash(String x) { + final l = config.c.hashViewBlockLength; + return x.substring(0, l) + '-' + x.substring(l, l * 2) + ' ...'; +} Map cleanKey(Map x) { final _cleaned = x.map