Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnidenifiedUser committed Jan 24, 2024
1 parent 1ae68e7 commit c51e49d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
4 changes: 3 additions & 1 deletion protocols/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ keywords = ["stratum", "mining", "bitcoin", "protocol"]

[workspace]

resolver="2"

members = [
"v1",
"v2/binary-sv2/serde-sv2",
Expand All @@ -38,4 +40,4 @@ opt-level = 1

[profile.test]
# Required by super_safe_lock
opt-level = 1
opt-level = 1
4 changes: 3 additions & 1 deletion roles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ keywords = ["stratum", "mining", "bitcoin", "protocol"]

[workspace]

resolver="2"

members = [
"mining-proxy",
"pool",
Expand All @@ -30,4 +32,4 @@ opt-level = 1

[profile.test]
# Required by super_safe_lock
opt-level = 1
opt-level = 1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
{
"output_string": "MATCHED MESSAGE TYPE 1",
"output_location": "StdOut",
"late_condition": false,
"condition": true
}
],
Expand Down
1 change: 1 addition & 0 deletions utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ license-file = "LICENSE.md"
keywords = ["stratum", "mining", "bitcoin", "protocol"]

[workspace]
resolver="2"

members = [
"network-helpers",
Expand Down
4 changes: 3 additions & 1 deletion utils/message-generator/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ impl Executor {
while pid.is_some() {
let p = process[index].as_mut();
pid = p.as_ref().unwrap().id();
p.unwrap().kill().await.expect("Failed to kill process");
if p.unwrap().kill().await.is_err() {
error!("Process already dead");
};
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
}
let _p = process[index].as_mut();
Expand Down
21 changes: 1 addition & 20 deletions utils/message-generator/src/executor_sv1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@ use async_channel::{Receiver, Sender};
use std::{collections::HashMap, sync::Arc};
use v1::Message;

use tokio::{
fs::File,
io::{copy, BufReader, BufWriter},
};
use tracing::{debug, error, info};

pub struct Sv1Executor {
#[allow(dead_code)]
name: Arc<String>,
send_to_up: Option<Sender<String>>,
recv_from_up: Option<Receiver<String>>,
Expand Down Expand Up @@ -174,26 +171,10 @@ impl Sv1Executor {
.await
.unwrap();
}
let mut child_no = 0;

#[allow(clippy::manual_flatten)]
for child in self.process {
if let Some(mut child) = child {
// Spawn a task to read the child process's stdout and write it to the file
let stdout = child.stdout.take().unwrap();
let mut stdout_reader = BufReader::new(stdout);
child_no += 1;
let test_name = self.name.clone();
tokio::spawn(async move {
let test_name = &*test_name;
let mut file = File::create(format!("{}.child-{}.log", test_name, child_no))
.await
.unwrap();
let mut stdout_writer = BufWriter::new(&mut file);

copy(&mut stdout_reader, &mut stdout_writer).await.unwrap();
});

while child.id().is_some() {
// Sends kill signal and waits 1 second before checking to ensure child was killed
child.kill().await.expect("Failed to kill process");
Expand Down

0 comments on commit c51e49d

Please sign in to comment.