bin/taud: minor changes & clean up

This commit is contained in:
ghassmo
2022-03-09 18:05:17 +04:00
parent eb6db85d4c
commit 241375e519
3 changed files with 10 additions and 24 deletions

1
Cargo.lock generated
View File

@@ -5302,7 +5302,6 @@ dependencies = [
"async-std",
"async-trait",
"darkfi",
"easy-parallel",
"futures",
"log",
"num_cpus",

View File

@@ -17,7 +17,6 @@ async-std = {version = "1.10.0", features = ["attributes"]}
async-trait = "0.1.52"
async-channel = "1.6.1"
async-executor = "1.4.1"
easy-parallel = "3.2.0"
# Misc
log = "0.4.14"

View File

@@ -1,5 +1,14 @@
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
sync::Arc,
};
use async_executor::Executor;
use async_trait::async_trait;
use log::debug;
use serde_json::{json, Value};
use simplelog::{ColorChoice, LevelFilter, TermLogger, TerminalMode};
use darkfi::{
rpc::{
jsonrpc::{error as jsonerr, response as jsonresp, ErrorCode::*, JsonRequest, JsonResult},
@@ -7,14 +16,6 @@ use darkfi::{
},
Result,
};
use easy_parallel::Parallel;
use log::debug;
use serde_json::{json, Value};
use simplelog::{ColorChoice, LevelFilter, TermLogger, TerminalMode};
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
sync::Arc,
};
async fn start(executor: Arc<Executor<'_>>) -> Result<()> {
let rpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 7777);
@@ -67,19 +68,6 @@ async fn main() -> Result<()> {
ColorChoice::Auto,
)?;
let nthreads = num_cpus::get();
let (signal, shutdown) = async_channel::unbounded::<()>();
let ex = Arc::new(Executor::new());
let ex3 = ex.clone();
let (_, result) = Parallel::new()
.each(0..nthreads, |_| smol::future::block_on(ex.run(shutdown.recv())))
.finish(|| {
smol::future::block_on(async move {
start(ex3.clone()).await?;
drop(signal);
Ok::<(), darkfi::Error>(())
})
});
result
smol::block_on(start(ex))
}