Update jsonrpc dependencies and rewrite dapps to futures. (#6522)
* Bump version. * Fix RPC crate. * Fix BoxFuture in crates. * Compiles and passes tests! * Get rid of .boxed() * Fixing issues with the UI. * Remove minihttp. Support threads. * Reimplement files serving to do it in chunks. * Increase chunk size. * Remove some unecessary copying. * Fix tests. * Fix stratum warning and ipfs todo. * Switch to proper branch of jsonrpc. * Update Cargo.lock. * Update docs. * Include dapps-glue in workspace. * fixed merge artifacts * Fix test compilation.
This commit is contained in:
committed by
Arkadiy Paronyan
parent
492da38d67
commit
e8b418ca03
@@ -20,24 +20,26 @@
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate mime;
|
||||
|
||||
extern crate ethabi;
|
||||
extern crate ethcore_util as util;
|
||||
extern crate ethcore_bigint as bigint;
|
||||
extern crate ethcore_bytes as bytes;
|
||||
extern crate futures;
|
||||
extern crate hash;
|
||||
extern crate mime;
|
||||
extern crate mime_guess;
|
||||
extern crate native_contracts;
|
||||
extern crate parity_reactor;
|
||||
extern crate parking_lot;
|
||||
extern crate rand;
|
||||
extern crate rustc_hex;
|
||||
extern crate hash;
|
||||
|
||||
pub extern crate fetch;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate parking_lot;
|
||||
#[cfg(test)]
|
||||
extern crate ethabi;
|
||||
|
||||
mod client;
|
||||
|
||||
pub mod urlhint;
|
||||
|
||||
@@ -18,15 +18,19 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use rustc_hex::ToHex;
|
||||
use mime::Mime;
|
||||
use mime::{self, Mime};
|
||||
use mime_guess;
|
||||
use hash::keccak;
|
||||
|
||||
use futures::{future, BoxFuture, Future};
|
||||
use futures::{future, Future};
|
||||
use native_contracts::{Registry, Urlhint};
|
||||
use util::Address;
|
||||
use bytes::Bytes;
|
||||
|
||||
/// Boxed future that can be shared between threads.
|
||||
/// TODO [ToDr] Use concrete types!
|
||||
pub type BoxFuture<A, B> = Box<Future<Item = A, Error = B> + Send>;
|
||||
|
||||
const COMMIT_LEN: usize = 20;
|
||||
|
||||
/// RAW Contract interface.
|
||||
@@ -127,7 +131,7 @@ fn decode_urlhint_output(output: (String, ::bigint::hash::H160, Address)) -> Opt
|
||||
|
||||
let commit = GithubApp::commit(&commit);
|
||||
if commit == Some(Default::default()) {
|
||||
let mime = guess_mime_type(&account_slash_repo).unwrap_or(mime!(Application/_));
|
||||
let mime = guess_mime_type(&account_slash_repo).unwrap_or(mime::APPLICATION_JSON);
|
||||
return Some(URLHintResult::Content(Content {
|
||||
url: account_slash_repo,
|
||||
mime: mime,
|
||||
@@ -158,7 +162,8 @@ impl URLHint for URLHintContract {
|
||||
let do_call = |_, data| {
|
||||
let addr = match self.client.registrar() {
|
||||
Ok(addr) => addr,
|
||||
Err(e) => return future::err(e).boxed(),
|
||||
Err(e) => return Box::new(future::err(e))
|
||||
as BoxFuture<Vec<u8>, _>,
|
||||
};
|
||||
|
||||
self.client.call(addr, data)
|
||||
@@ -166,7 +171,7 @@ impl URLHint for URLHintContract {
|
||||
|
||||
let urlhint = self.urlhint.clone();
|
||||
let client = self.client.clone();
|
||||
self.registrar.get_address(do_call, keccak("githubhint"), "A".into())
|
||||
Box::new(self.registrar.get_address(do_call, keccak("githubhint"), "A".into())
|
||||
.map(|addr| if addr == Address::default() { None } else { Some(addr) })
|
||||
.and_then(move |address| {
|
||||
let mut fixed_id = [0; 32];
|
||||
@@ -180,7 +185,7 @@ impl URLHint for URLHintContract {
|
||||
Either::B(urlhint.entries(do_call, ::bigint::hash::H256(fixed_id)).map(decode_urlhint_output))
|
||||
}
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +218,7 @@ pub mod tests {
|
||||
use std::str::FromStr;
|
||||
use rustc_hex::FromHex;
|
||||
|
||||
use futures::{BoxFuture, Future, IntoFuture};
|
||||
use futures::{Future, IntoFuture};
|
||||
|
||||
use super::*;
|
||||
use super::guess_mime_type;
|
||||
@@ -251,7 +256,7 @@ pub mod tests {
|
||||
fn call(&self, address: Address, data: Bytes) -> BoxFuture<Bytes, String> {
|
||||
self.calls.lock().push((address.to_hex(), data.to_hex()));
|
||||
let res = self.responses.lock().remove(0);
|
||||
res.into_future().boxed()
|
||||
Box::new(res.into_future())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +331,7 @@ pub mod tests {
|
||||
// then
|
||||
assert_eq!(res, Some(URLHintResult::Content(Content {
|
||||
url: "https://parity.io/assets/images/ethcore-black-horizontal.png".into(),
|
||||
mime: mime!(Image/Png),
|
||||
mime: mime::IMAGE_PNG,
|
||||
owner: Address::from_str("deadcafebeefbeefcafedeaddeedfeedffffffff").unwrap(),
|
||||
})))
|
||||
}
|
||||
@@ -358,9 +363,9 @@ pub mod tests {
|
||||
|
||||
|
||||
assert_eq!(guess_mime_type(url1), None);
|
||||
assert_eq!(guess_mime_type(url2), Some(mime!(Image/Png)));
|
||||
assert_eq!(guess_mime_type(url3), Some(mime!(Image/Png)));
|
||||
assert_eq!(guess_mime_type(url4), Some(mime!(Image/Jpeg)));
|
||||
assert_eq!(guess_mime_type(url5), Some(mime!(Image/Png)));
|
||||
assert_eq!(guess_mime_type(url2), Some(mime::IMAGE_PNG));
|
||||
assert_eq!(guess_mime_type(url3), Some(mime::IMAGE_PNG));
|
||||
assert_eq!(guess_mime_type(url4), Some(mime::IMAGE_JPEG));
|
||||
assert_eq!(guess_mime_type(url5), Some(mime::IMAGE_PNG));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user