mirror of
https://github.com/wownero/cyberwow.git
synced 2026-10-24 02:38:47 +02:00
enable stdin
This commit is contained in:
@@ -54,16 +54,25 @@ Stream<String> runBinary (String name, {Stream<String> 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<void> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ReSyncingState> 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();
|
||||
|
||||
Reference in New Issue
Block a user