mirror of
https://github.com/mimblewimble/mwixnet.git
synced 2025-01-20 19:11:09 +03:00
Merge pull request #28 from yeastplume/deps_bugs
Create separate context for TOR runtime
This commit is contained in:
commit
51399a6d02
4 changed files with 22 additions and 13 deletions
|
@ -161,14 +161,17 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()?;
|
.build()?;
|
||||||
if let Err(e) = rt.block_on(node.async_get_chain_tip()) {
|
|
||||||
|
let rt_handle = rt.handle().clone();
|
||||||
|
|
||||||
|
if let Err(e) = rt_handle.block_on(node.async_get_chain_tip()) {
|
||||||
eprintln!("Node communication failure. Is node listening?");
|
eprintln!("Node communication failure. Is node listening?");
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
};
|
};
|
||||||
|
|
||||||
// Open wallet
|
// Open wallet
|
||||||
let wallet_pass = prompt_wallet_password(&args.value_of("wallet_pass"));
|
let wallet_pass = prompt_wallet_password(&args.value_of("wallet_pass"));
|
||||||
let wallet = rt.block_on(HttpWallet::async_open_wallet(
|
let wallet = rt_handle.block_on(HttpWallet::async_open_wallet(
|
||||||
&server_config.wallet_owner_url,
|
&server_config.wallet_owner_url,
|
||||||
&server_config.wallet_owner_api_secret(),
|
&server_config.wallet_owner_api_secret(),
|
||||||
&wallet_pass,
|
&wallet_pass,
|
||||||
|
@ -181,8 +184,14 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let tor_instance = rt.block_on(tor::async_init_tor(
|
let tor_runtime = if let Ok(r) = PreferredRuntime::create() {
|
||||||
PreferredRuntime::current().unwrap(),
|
r
|
||||||
|
} else {
|
||||||
|
return Err("No runtime found".into());
|
||||||
|
};
|
||||||
|
|
||||||
|
let tor_instance = rt_handle.block_on(tor::async_init_tor(
|
||||||
|
tor_runtime,
|
||||||
&config::get_grin_path(&chain_type).to_str().unwrap(),
|
&config::get_grin_path(&chain_type).to_str().unwrap(),
|
||||||
&server_config,
|
&server_config,
|
||||||
))?;
|
))?;
|
||||||
|
@ -192,7 +201,7 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let stop_state = Arc::new(StopState::new());
|
let stop_state = Arc::new(StopState::new());
|
||||||
let stop_state_clone = stop_state.clone();
|
let stop_state_clone = stop_state.clone();
|
||||||
|
|
||||||
rt.spawn(async move {
|
rt_handle.spawn(async move {
|
||||||
futures::executor::block_on(build_signals_fut());
|
futures::executor::block_on(build_signals_fut());
|
||||||
tor_clone.lock().stop();
|
tor_clone.lock().stop();
|
||||||
stop_state_clone.stop();
|
stop_state_clone.stop();
|
||||||
|
@ -215,7 +224,7 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
);
|
);
|
||||||
|
|
||||||
let (_, http_server) = servers::mix_rpc::listen(
|
let (_, http_server) = servers::mix_rpc::listen(
|
||||||
rt.handle(),
|
&rt_handle,
|
||||||
server_config,
|
server_config,
|
||||||
next_mixer,
|
next_mixer,
|
||||||
Arc::new(wallet),
|
Arc::new(wallet),
|
||||||
|
|
|
@ -70,7 +70,7 @@ impl IntegrationGrinNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_client(&self) -> Arc<dyn GrinNode> {
|
pub fn to_client(&self) -> Arc<dyn GrinNode> {
|
||||||
Arc::new(HttpGrinNode::new(&self.api_address(), &None))
|
Arc::new(HttpGrinNode::new(&self.api_address().to_string(), &None))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ where
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.local_addr()
|
.local_addr()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
grin_node_url: node.lock().api_address(),
|
grin_node_url: node.lock().api_address().to_string(),
|
||||||
grin_node_secret_path: None,
|
grin_node_secret_path: None,
|
||||||
wallet_owner_url: wallet.lock().owner_address(),
|
wallet_owner_url: wallet.lock().owner_address().to_string(),
|
||||||
wallet_owner_secret_path: None,
|
wallet_owner_secret_path: None,
|
||||||
prev_server: None,
|
prev_server: None,
|
||||||
next_server: match next_server {
|
next_server: match next_server {
|
||||||
|
@ -128,9 +128,9 @@ where
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.local_addr()
|
.local_addr()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
grin_node_url: node.lock().api_address(),
|
grin_node_url: node.lock().api_address().to_string(),
|
||||||
grin_node_secret_path: None,
|
grin_node_secret_path: None,
|
||||||
wallet_owner_url: wallet.lock().owner_address(),
|
wallet_owner_url: wallet.lock().owner_address().to_string(),
|
||||||
wallet_owner_secret_path: None,
|
wallet_owner_secret_path: None,
|
||||||
prev_server: Some(prev_server),
|
prev_server: Some(prev_server),
|
||||||
next_server: match next_server {
|
next_server: match next_server {
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl IntegrationGrinWallet {
|
||||||
let owner_api = Arc::new(Owner::new(wallet.clone(), None));
|
let owner_api = Arc::new(Owner::new(wallet.clone(), None));
|
||||||
|
|
||||||
let address_str = format!("127.0.0.1:{}", api_listen_port);
|
let address_str = format!("127.0.0.1:{}", api_listen_port);
|
||||||
let owner_addr: SocketAddr = address_str.parse().unwrap();
|
let address_str_2 = format!("127.0.0.1:{}", api_listen_port);
|
||||||
let thr_wallet = wallet.clone();
|
let thr_wallet = wallet.clone();
|
||||||
let _thread_handle = thread::spawn(move || {
|
let _thread_handle = thread::spawn(move || {
|
||||||
controller::owner_listener(
|
controller::owner_listener(
|
||||||
|
@ -125,7 +125,7 @@ impl IntegrationGrinWallet {
|
||||||
});
|
});
|
||||||
|
|
||||||
let http_client = Arc::new(
|
let http_client = Arc::new(
|
||||||
HttpWallet::async_open_wallet(&owner_addr, &None, &ZeroingString::from("pass"))
|
HttpWallet::async_open_wallet(&address_str_2, &None, &ZeroingString::from("pass"))
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue