Merge branch 'master' into unitdiff

This commit is contained in:
Ignotus Peverell
2018-10-25 14:20:41 -07:00
committed by GitHub
131 changed files with 1942 additions and 2372 deletions
+7 -12
View File
@@ -14,7 +14,8 @@
use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::{Arc, RwLock, Weak};
use std::sync::{Arc, Weak};
use util::RwLock;
use failure::ResultExt;
use futures::future::ok;
@@ -36,7 +37,6 @@ use types::*;
use url::form_urlencoded;
use util;
use util::secp::pedersen::Commitment;
use util::LOGGER;
use web::*;
// All handlers use `Weak` references instead of `Arc` to avoid cycles that
@@ -205,12 +205,8 @@ impl OutputHandler {
}
debug!(
LOGGER,
"outputs_block_batch: {}-{}, {:?}, {:?}",
start_height,
end_height,
commitments,
include_rp,
start_height, end_height, commitments, include_rp,
);
let mut return_vec = vec![];
@@ -695,7 +691,7 @@ struct PoolInfoHandler {
impl Handler for PoolInfoHandler {
fn get(&self, _req: Request<Body>) -> ResponseFuture {
let pool_arc = w(&self.tx_pool);
let pool = pool_arc.read().unwrap();
let pool = pool_arc.read();
json_response(&PoolInfo {
pool_size: pool.total_size(),
@@ -744,7 +740,6 @@ impl PoolPushHandler {
identifier: "?.?.?.?".to_string(),
};
info!(
LOGGER,
"Pushing transaction {} to pool (inputs: {}, outputs: {}, kernels: {})",
tx.hash(),
tx.inputs().len(),
@@ -753,12 +748,12 @@ impl PoolPushHandler {
);
// Push to tx pool.
let mut tx_pool = pool_arc.write().unwrap();
let mut tx_pool = pool_arc.write();
let header = tx_pool.blockchain.chain_head().unwrap();
tx_pool
.add_to_pool(source, tx, !fluff, &header)
.map_err(|e| {
error!(LOGGER, "update_pool: failed with error: {:?}", e);
error!("update_pool: failed with error: {:?}", e);
ErrorKind::Internal(format!("Failed to update pool: {:?}", e)).into()
})
}),
@@ -807,7 +802,7 @@ pub fn start_rest_apis(
router.add_middleware(basic_auth_middleware);
}
info!(LOGGER, "Starting HTTP API server at {}.", addr);
info!("Starting HTTP API server at {}.", addr);
let socket_addr: SocketAddr = addr.parse().expect("unable to parse socket address");
apis.start(socket_addr, router, tls_config).is_ok()
}
+1 -1
View File
@@ -33,7 +33,7 @@ extern crate serde;
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
extern crate slog;
extern crate log;
extern crate futures;
extern crate http;
extern crate hyper_rustls;
+3 -7
View File
@@ -33,7 +33,6 @@ use std::sync::Arc;
use std::{io, thread};
use tokio_rustls::ServerConfigExt;
use tokio_tcp;
use util::LOGGER;
/// Errors that can be returned by an ApiEndpoint implementation.
#[derive(Debug)]
@@ -243,13 +242,10 @@ impl ApiServer {
// TODO re-enable stop after investigation
//let tx = mem::replace(&mut self.shutdown_sender, None).unwrap();
//tx.send(()).expect("Failed to stop API server");
info!(LOGGER, "API server has been stoped");
info!("API server has been stoped");
true
} else {
error!(
LOGGER,
"Can't stop API server, it's not running or doesn't spport stop operation"
);
error!("Can't stop API server, it's not running or doesn't spport stop operation");
false
}
}
@@ -263,7 +259,7 @@ impl Handler for LoggingMiddleware {
req: Request<Body>,
mut handlers: Box<Iterator<Item = HandlerObj>>,
) -> ResponseFuture {
debug!(LOGGER, "REST call: {} {}", req.method(), req.uri().path());
debug!("REST call: {} {}", req.method(), req.uri().path());
handlers.next().unwrap().call(req, handlers)
}
}