diff --git a/cyberwow/lib/controller/syncing.dart b/cyberwow/lib/controller/syncing.dart index c3b1513..a1d7956 100644 --- a/cyberwow/lib/controller/syncing.dart +++ b/cyberwow/lib/controller/syncing.dart @@ -54,16 +54,25 @@ Stream runBinary (String name, {Stream input}) async* { [ "--data-dir", binDir.path, - "--non-interactive", ] + extraArgs + config.c.extraArgs; log.info('args: ' + args.toString()); final outputProcess = await Process.start(newPath, args); + + Future printInput() async { + await for (final line in input) { + log.finest('process input: ' + line); + outputProcess.stdin.writeln(line); + outputProcess.stdin.flush(); + } + } + if (input != null) { - outputProcess.stdin.addStream(input.transform(utf8.encoder)); + printInput(); } await for (final line in outputProcess.stdout.transform(utf8.decoder)) { + log.finest('process output: ' + line); yield line; } diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index 359aa59..fde28ed 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -190,6 +190,8 @@ class SyncingState extends HookedState { log.fine('syncing: loop exit'); + // processInput.add('exit'); + final _height = await rpc.height(); SyncedState _next = SyncedState(setState, getNotification, stdout, processInput, processOutput); _next.height = _height; @@ -211,6 +213,11 @@ class SyncedState extends HookedState { SyncedState(f, s, this.stdout, this.processInput, this.processOutput) : super (f, s); + void appendInput(String line) { + stdout.addLast('> ' + line + '\n'); + processInput.add(line); + } + Future next() async { log.fine("Synced next"); @@ -241,7 +248,7 @@ class SyncedState extends HookedState { getTransactionPool = await rpc.getTransactionPoolSimple(); - // processInput.add('help\n'); + // appendInput('help'); // log.fine('getTransactionPool: $getTransactionPool'); syncState();