diff --git a/src/helper.rs b/src/helper.rs index ababd9b..2666307 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -271,6 +271,18 @@ impl Helper { fn read_pty_xmrig(output_parse: Arc>, output_pub: Arc>, reader: Box) { use std::io::BufRead; let mut stdout = std::io::BufReader::new(reader).lines(); + + // Run a ANSI escape sequence filter for the first few lines. + for (i, line) in stdout.next().enumerate() { + let Some(Ok(line)) = line else { continue; } + let line = strip_ansi_escapes::strip_str(line); + if let Err(e) = writeln!(lock!(output_parse), "{}", line) { error!("XMRig PTY Parse | Output error: {}", e); } + if let Err(e) = writeln!(lock!(output_pub), "{}", line) { error!("XMRig PTY Pub | Output error: {}", e); } + if i > 20 { + break; + } + } + while let Some(Ok(line)) = stdout.next() { // println!("{}", line); // For debugging. if let Err(e) = writeln!(lock!(output_parse), "{}", line) { error!("XMRig PTY Parse | Output error: {}", e); } @@ -281,6 +293,18 @@ impl Helper { fn read_pty_p2pool(output_parse: Arc>, output_pub: Arc>, reader: Box, gupax_p2pool_api: Arc>) { use std::io::BufRead; let mut stdout = std::io::BufReader::new(reader).lines(); + + // Run a ANSI escape sequence filter for the first few lines. + for (i, line) in stdout.next().enumerate() { + let Some(Ok(line)) = line else { continue; } + let line = strip_ansi_escapes::strip_str(line); + if let Err(e) = writeln!(lock!(output_parse), "{}", line) { error!("P2Pool PTY Parse | Output error: {}", e); } + if let Err(e) = writeln!(lock!(output_pub), "{}", line) { error!("P2Pool PTY Pub | Output error: {}", e); } + if i > 20 { + break; + } + } + while let Some(Ok(line)) = stdout.next() { // println!("{}", line); // For debugging. if P2POOL_REGEX.payout.is_match(&line) {