[ipfs] Convert to edition 2018 (#10979)
* [ipfs] Converto to edition 2018 Also: whitespace * Review feedback
This commit is contained in:
parent
fbf425c4e2
commit
b1e3acaf0c
@ -4,15 +4,16 @@ name = "parity-ipfs-api"
|
||||
version = "1.12.0"
|
||||
license = "GPL-3.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
client-traits = { path = "../ethcore/client-traits" }
|
||||
common-types = { path = "../ethcore/types" }
|
||||
ethcore = { path = "../ethcore" }
|
||||
parity-bytes = "0.1"
|
||||
bytes = { package = "parity-bytes", version = "0.1"}
|
||||
ethereum-types = "0.6.0"
|
||||
jsonrpc-core = "12.0.0"
|
||||
jsonrpc-http-server = "12.0.0"
|
||||
core = { package = "jsonrpc-core", version = "12.0.0"}
|
||||
http = { package = "jsonrpc-http-server", version = "12.0.0"}
|
||||
rlp = "0.4.0"
|
||||
cid = "0.3"
|
||||
multihash = "0.8"
|
||||
|
@ -14,16 +14,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use {multihash, cid, http};
|
||||
use route::Out;
|
||||
use crate::route::Out;
|
||||
|
||||
pub type Result<T> = ::std::result::Result<T, Error>;
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// IPFS server error
|
||||
#[derive(Debug)]
|
||||
pub enum ServerError {
|
||||
/// Wrapped `std::io::Error`
|
||||
IoError(::std::io::Error),
|
||||
IoError(std::io::Error),
|
||||
/// Other `hyper` error
|
||||
Other(http::hyper::error::Error),
|
||||
/// Invalid --ipfs-api-interface
|
||||
@ -31,8 +30,8 @@ pub enum ServerError {
|
||||
}
|
||||
|
||||
/// Handle IO errors (ports taken when starting the server).
|
||||
impl From<::std::io::Error> for ServerError {
|
||||
fn from(err: ::std::io::Error) -> ServerError {
|
||||
impl From<std::io::Error> for ServerError {
|
||||
fn from(err: std::io::Error) -> ServerError {
|
||||
ServerError::IoError(err)
|
||||
}
|
||||
}
|
||||
@ -53,8 +52,8 @@ impl From<ServerError> for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Display for ServerError {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
impl std::fmt::Display for ServerError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
ServerError::IoError(err) => write!(f, "Io Error: {}", err),
|
||||
ServerError::Other(err) => write!(f, "Other error: {}", err),
|
||||
@ -63,7 +62,7 @@ impl ::std::fmt::Display for ServerError {
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::error::Error for ServerError {}
|
||||
impl std::error::Error for ServerError {}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
|
@ -14,19 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate multihash;
|
||||
extern crate cid;
|
||||
extern crate unicase;
|
||||
|
||||
extern crate rlp;
|
||||
extern crate client_traits;
|
||||
extern crate common_types;
|
||||
extern crate ethcore;
|
||||
extern crate parity_bytes as bytes;
|
||||
extern crate ethereum_types;
|
||||
extern crate jsonrpc_core as core;
|
||||
extern crate jsonrpc_http_server as http;
|
||||
|
||||
pub mod error;
|
||||
mod route;
|
||||
|
||||
@ -53,19 +40,19 @@ pub struct IpfsHandler {
|
||||
/// Hostnames allowed in the `Host` request header
|
||||
allowed_hosts: Option<Vec<Host>>,
|
||||
/// Reference to the Blockchain Client
|
||||
client: Arc<BlockChainClient>,
|
||||
client: Arc<dyn BlockChainClient>,
|
||||
}
|
||||
|
||||
impl IpfsHandler {
|
||||
pub fn client(&self) -> &BlockChainClient {
|
||||
pub fn client(&self) -> &dyn BlockChainClient {
|
||||
&*self.client
|
||||
}
|
||||
|
||||
pub fn new(cors: DomainsValidation<AccessControlAllowOrigin>, hosts: DomainsValidation<Host>, client: Arc<BlockChainClient>) -> Self {
|
||||
pub fn new(cors: DomainsValidation<AccessControlAllowOrigin>, hosts: DomainsValidation<Host>, client: Arc<dyn BlockChainClient>) -> Self {
|
||||
IpfsHandler {
|
||||
cors_domains: cors.into(),
|
||||
allowed_hosts: hosts.into(),
|
||||
client: client,
|
||||
client,
|
||||
}
|
||||
}
|
||||
pub fn on_request(&self, req: hyper::Request<Body>) -> (Option<HeaderValue>, Out) {
|
||||
@ -156,7 +143,7 @@ pub fn start_server(
|
||||
interface: String,
|
||||
cors: DomainsValidation<AccessControlAllowOrigin>,
|
||||
hosts: DomainsValidation<Host>,
|
||||
client: Arc<BlockChainClient>
|
||||
client: Arc<dyn BlockChainClient>
|
||||
) -> Result<Listening, ServerError> {
|
||||
|
||||
let ip: IpAddr = interface.parse().map_err(|_| ServerError::InvalidInterface)?;
|
||||
|
@ -14,14 +14,17 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use {rlp, multihash, IpfsHandler};
|
||||
use error::{Error, Result};
|
||||
use cid::{ToCid, Codec};
|
||||
use crate::{
|
||||
IpfsHandler,
|
||||
error::{Error, Result},
|
||||
};
|
||||
|
||||
use common_types::ids::{BlockId, TransactionId};
|
||||
use multihash::Hash;
|
||||
use ethereum_types::H256;
|
||||
use bytes::Bytes;
|
||||
use cid::{ToCid, Codec};
|
||||
use common_types::ids::{BlockId, TransactionId};
|
||||
use ethereum_types::H256;
|
||||
use multihash::{self, Hash};
|
||||
use rlp;
|
||||
|
||||
type Reason = &'static str;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user