Fix compilation issues (#344)

This commit is contained in:
jaspervdm
2020-02-24 22:39:32 +01:00
committed by GitHub
parent bf27520bd2
commit b56afda5f9
6 changed files with 185 additions and 166 deletions
+14 -7
View File
@@ -15,6 +15,7 @@
//! High level JSON/HTTP client API
use crate::util::to_base64;
use crossbeam_utils::thread::scope;
use failure::{Backtrace, Context, Fail, ResultExt};
use hyper::body;
use hyper::header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, USER_AGENT};
@@ -39,7 +40,7 @@ pub enum ErrorKind {
#[fail(display = "Internal error: {}", _0)]
Internal(String),
#[fail(display = "Bad arguments: {}", _0)]
Argument(String),
_Argument(String),
#[fail(display = "Not found.")]
_NotFound,
#[fail(display = "Request error: {}", _0)]
@@ -323,11 +324,17 @@ impl Client {
pub fn send_request(&self, req: Request<Body>) -> Result<String, Error> {
let task = self.send_request_async(req);
let mut rt = Builder::new()
.basic_scheduler()
.enable_all()
.build()
.context(ErrorKind::Internal("can't create Tokio runtime".to_owned()))?;
rt.block_on(task)
scope(|s| {
let handle = s.spawn(|_| {
let mut rt = Builder::new()
.basic_scheduler()
.enable_all()
.build()
.context(ErrorKind::Internal("can't create Tokio runtime".to_owned()))?;
rt.block_on(task)
});
handle.join().unwrap()
})
.unwrap()
}
}
+15 -6
View File
@@ -17,6 +17,7 @@
use crate::api::{self, LocatedTxKernel, OutputListing, OutputPrintable};
use crate::core::core::{Transaction, TxKernel};
use crate::libwallet::{NodeClient, NodeVersionInfo};
use crossbeam_utils::thread::scope;
use futures::stream::FuturesUnordered;
use futures::TryStreamExt;
use std::collections::HashMap;
@@ -250,12 +251,20 @@ impl NodeClient for HTTPNodeClient {
task.try_collect().await
};
let mut rt = Builder::new()
.threaded_scheduler()
.enable_all()
.build()
.unwrap();
let res: Result<Vec<Response>, _> = rt.block_on(task);
let res = scope(|s| {
let handle = s.spawn(|_| {
let mut rt = Builder::new()
.threaded_scheduler()
.enable_all()
.build()
.unwrap();
let res: Result<Vec<Response>, _> = rt.block_on(task);
res
});
handle.join().unwrap()
})
.unwrap();
let results: Vec<OutputPrintable> = match res {
Ok(resps) => {
let mut results = vec![];