updates to ensure compilation against grin 5.0.2 (#644)

This commit is contained in:
Yeastplume 2022-03-21 10:45:53 +00:00 committed by GitHub
parent cecb084753
commit fa39fca201
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 405 additions and 359 deletions

735
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -24,6 +24,7 @@ use crate::libwallet::{
use crate::util::secp::key::SecretKey; use crate::util::secp::key::SecretKey;
use crate::util::{from_hex, static_secp_instance, to_base64, Mutex}; use crate::util::{from_hex, static_secp_instance, to_base64, Mutex};
use failure::ResultExt; use failure::ResultExt;
use futures::channel::oneshot;
use grin_wallet_api::JsonId; use grin_wallet_api::JsonId;
use grin_wallet_config::types::{TorBridgeConfig, TorProxyConfig}; use grin_wallet_config::types::{TorBridgeConfig, TorProxyConfig};
use grin_wallet_util::OnionV3Address; use grin_wallet_util::OnionV3Address;
@ -261,14 +262,17 @@ where
.map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?; .map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?;
} }
let api_chan: &'static mut (oneshot::Sender<()>, oneshot::Receiver<()>) =
Box::leak(Box::new(oneshot::channel::<()>()));
let mut apis = ApiServer::new(); let mut apis = ApiServer::new();
warn!("Starting HTTP Owner API server at {}.", addr); warn!("Starting HTTP Owner API server at {}.", addr);
let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address"); let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address");
let api_thread = let api_thread = apis
apis.start(socket_addr, router, tls_config) .start(socket_addr, router, tls_config, api_chan)
.context(ErrorKind::GenericError( .context(ErrorKind::GenericError(
"API thread failed to start".to_string(), "API thread failed to start".to_string(),
))?; ))?;
warn!("HTTP Owner listener started."); warn!("HTTP Owner listener started.");
api_thread api_thread
.join() .join()
@ -333,14 +337,17 @@ where
.add_route("/v2/foreign", Arc::new(api_handler_v2)) .add_route("/v2/foreign", Arc::new(api_handler_v2))
.map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?; .map_err(|_| ErrorKind::GenericError("Router failed to add route".to_string()))?;
let api_chan: &'static mut (oneshot::Sender<()>, oneshot::Receiver<()>) =
Box::leak(Box::new(oneshot::channel::<()>()));
let mut apis = ApiServer::new(); let mut apis = ApiServer::new();
warn!("Starting HTTP Foreign listener API server at {}.", addr); warn!("Starting HTTP Foreign listener API server at {}.", addr);
let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address"); let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address");
let api_thread = let api_thread = apis
apis.start(socket_addr, router, tls_config) .start(socket_addr, router, tls_config, api_chan)
.context(ErrorKind::GenericError( .context(ErrorKind::GenericError(
"API thread failed to start".to_string(), "API thread failed to start".to_string(),
))?; ))?;
warn!("HTTP Foreign listener started."); warn!("HTTP Foreign listener started.");
if let Some(a) = address { if let Some(a) = address {

View file

@ -333,7 +333,7 @@ where
{ {
// TODO: change create_post_request to accept a url instead of a &str // TODO: change create_post_request to accept a url instead of a &str
let req = api::client::create_post_request(url.as_str(), api_secret, input)?; let req = api::client::create_post_request(url.as_str(), api_secret, input)?;
let res = api::client::send_request(req)?; let res = api::client::send_request(req, api::client::TimeOut::default())?;
Ok(res) Ok(res)
} }