Serde 0.9 (#4508)
* Porting json * Dapps * Rpc & Ethstore * New ethabi * Last bunch of fixes * Fixing last test * Removing build script * Adding ethcore-ipc-tests back * Fixing grumbles * Fixing blockchain tests (inference regression?)
This commit is contained in:
committed by
Nikolay Volf
parent
a2c6cd8f7b
commit
f1e99ea2e4
110
parity/main.rs
110
parity/main.rs
@@ -22,59 +22,52 @@
|
||||
#![cfg_attr(feature="dev", allow(useless_format))]
|
||||
#![cfg_attr(feature="dev", allow(match_bool))]
|
||||
|
||||
extern crate docopt;
|
||||
extern crate num_cpus;
|
||||
extern crate rustc_serialize;
|
||||
extern crate ethcore_devtools as devtools;
|
||||
extern crate ethcore;
|
||||
extern crate ethsync;
|
||||
extern crate env_logger;
|
||||
extern crate ethcore_logger;
|
||||
extern crate ansi_term;
|
||||
extern crate app_dirs;
|
||||
extern crate ctrlc;
|
||||
extern crate docopt;
|
||||
extern crate env_logger;
|
||||
extern crate fdlimit;
|
||||
extern crate time;
|
||||
extern crate hyper; // for price_info.rs
|
||||
extern crate isatty;
|
||||
extern crate jsonrpc_core;
|
||||
extern crate num_cpus;
|
||||
extern crate number_prefix;
|
||||
extern crate regex;
|
||||
extern crate rlp;
|
||||
extern crate rpassword;
|
||||
extern crate rustc_serialize;
|
||||
extern crate semver;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate ethcore_ipc as ipc;
|
||||
extern crate ethcore_ipc_nano as nanoipc;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate jsonrpc_core;
|
||||
extern crate rlp;
|
||||
extern crate ethcore_light as light;
|
||||
extern crate parity_hash_fetch as hash_fetch;
|
||||
|
||||
extern crate ethcore_ipc_hypervisor as hypervisor;
|
||||
extern crate ethcore_rpc;
|
||||
|
||||
extern crate ethcore_signer;
|
||||
extern crate parity_updater as updater;
|
||||
extern crate ansi_term;
|
||||
|
||||
extern crate regex;
|
||||
extern crate isatty;
|
||||
extern crate time;
|
||||
extern crate toml;
|
||||
extern crate app_dirs;
|
||||
extern crate parity_reactor;
|
||||
|
||||
#[macro_use]
|
||||
extern crate ethcore;
|
||||
extern crate ethcore_devtools as devtools;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate ethcore_ipc as ipc;
|
||||
extern crate ethcore_ipc_hypervisor as hypervisor;
|
||||
extern crate ethcore_ipc_nano as nanoipc;
|
||||
extern crate ethcore_light as light;
|
||||
extern crate ethcore_logger;
|
||||
extern crate ethcore_rpc;
|
||||
extern crate ethcore_signer;
|
||||
extern crate ethcore_util as util;
|
||||
#[macro_use]
|
||||
extern crate log as rlog;
|
||||
#[macro_use]
|
||||
extern crate hyper; // for price_info.rs
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate ethsync;
|
||||
extern crate parity_hash_fetch as hash_fetch;
|
||||
extern crate parity_reactor;
|
||||
extern crate parity_updater as updater;
|
||||
extern crate rpc_cli;
|
||||
|
||||
#[cfg(feature="stratum")]
|
||||
extern crate ethcore_stratum;
|
||||
|
||||
#[cfg(feature = "dapps")]
|
||||
extern crate ethcore_dapps;
|
||||
|
||||
extern crate rpc_cli;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log as rlog;
|
||||
|
||||
macro_rules! dependency {
|
||||
($dep_ty:ident, $url:expr) => {
|
||||
@@ -88,32 +81,33 @@ macro_rules! dependency {
|
||||
}
|
||||
}
|
||||
|
||||
mod cache;
|
||||
mod upgrade;
|
||||
mod rpc;
|
||||
mod dapps;
|
||||
mod informant;
|
||||
mod cli;
|
||||
mod configuration;
|
||||
mod migration;
|
||||
mod signer;
|
||||
mod rpc_apis;
|
||||
mod url;
|
||||
mod helpers;
|
||||
mod params;
|
||||
mod deprecated;
|
||||
mod dir;
|
||||
mod modules;
|
||||
mod account;
|
||||
mod blockchain;
|
||||
mod cache;
|
||||
mod cli;
|
||||
mod configuration;
|
||||
mod dapps;
|
||||
mod deprecated;
|
||||
mod dir;
|
||||
mod helpers;
|
||||
mod informant;
|
||||
mod migration;
|
||||
mod modules;
|
||||
mod params;
|
||||
mod presale;
|
||||
mod snapshot;
|
||||
mod rpc;
|
||||
mod rpc_apis;
|
||||
mod run;
|
||||
#[cfg(feature="ipc")]
|
||||
mod sync;
|
||||
mod signer;
|
||||
mod snapshot;
|
||||
mod upgrade;
|
||||
mod url;
|
||||
mod user_defaults;
|
||||
|
||||
#[cfg(feature="ipc")]
|
||||
mod boot;
|
||||
mod user_defaults;
|
||||
#[cfg(feature="ipc")]
|
||||
mod sync;
|
||||
|
||||
#[cfg(feature="stratum")]
|
||||
mod stratum;
|
||||
@@ -211,7 +205,7 @@ fn latest_exe_path() -> Option<PathBuf> {
|
||||
fn global_cleanup() {
|
||||
extern "system" { pub fn WSACleanup() -> i32; }
|
||||
// We need to cleanup all sockets before spawning another Parity process. This makes shure everything is cleaned up.
|
||||
// The loop is required because of internal refernce counter for winsock dll. We don't know how many crates we use do
|
||||
// The loop is required because of internal refernce counter for winsock dll. We don't know how many crates we use do
|
||||
// initialize it. There's at least 2 now.
|
||||
for _ in 0.. 10 {
|
||||
unsafe { WSACleanup(); }
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::collections::BTreeMap;
|
||||
use std::time::Duration;
|
||||
use serde::{Serialize, Serializer, Error, Deserialize, Deserializer};
|
||||
use serde::de::{Visitor, MapVisitor};
|
||||
use serde::{Serialize, Serializer, Deserialize, Deserializer};
|
||||
use serde::de::{Error, Visitor, MapVisitor};
|
||||
use serde::de::impls::BTreeMapVisitor;
|
||||
use serde_json::Value;
|
||||
use serde_json::de::from_reader;
|
||||
@@ -37,7 +38,7 @@ pub struct UserDefaults {
|
||||
}
|
||||
|
||||
impl Serialize for UserDefaults {
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where S: Serializer {
|
||||
let mut map: BTreeMap<String, Value> = BTreeMap::new();
|
||||
map.insert("pruning".into(), Value::String(self.pruning.as_str().into()));
|
||||
@@ -46,12 +47,12 @@ impl Serialize for UserDefaults {
|
||||
let mode_str = match self.mode {
|
||||
Mode::Off => "offline",
|
||||
Mode::Dark(timeout) => {
|
||||
map.insert("mode.timeout".into(), Value::U64(timeout.as_secs()));
|
||||
map.insert("mode.timeout".into(), Value::Number(timeout.as_secs().into()));
|
||||
"dark"
|
||||
},
|
||||
Mode::Passive(timeout, alarm) => {
|
||||
map.insert("mode.timeout".into(), Value::U64(timeout.as_secs()));
|
||||
map.insert("mode.alarm".into(), Value::U64(alarm.as_secs()));
|
||||
map.insert("mode.timeout".into(), Value::Number(timeout.as_secs().into()));
|
||||
map.insert("mode.alarm".into(), Value::Number(alarm.as_secs().into()));
|
||||
"passive"
|
||||
},
|
||||
Mode::Active => "active",
|
||||
@@ -65,7 +66,7 @@ impl Serialize for UserDefaults {
|
||||
struct UserDefaultsVisitor;
|
||||
|
||||
impl Deserialize for UserDefaults {
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where D: Deserializer {
|
||||
deserializer.deserialize(UserDefaultsVisitor)
|
||||
}
|
||||
@@ -74,8 +75,11 @@ impl Deserialize for UserDefaults {
|
||||
impl Visitor for UserDefaultsVisitor {
|
||||
type Value = UserDefaults;
|
||||
|
||||
fn visit_map<V>(&mut self, visitor: V) -> Result<Self::Value, V::Error>
|
||||
where V: MapVisitor {
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(formatter, "a valid UserDefaults object")
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, visitor: V) -> Result<Self::Value, V::Error> where V: MapVisitor {
|
||||
let mut map: BTreeMap<String, Value> = BTreeMapVisitor::new().visit_map(visitor)?;
|
||||
let pruning: Value = map.remove("pruning").ok_or_else(|| Error::custom("missing pruning"))?;
|
||||
let pruning = pruning.as_str().ok_or_else(|| Error::custom("invalid pruning value"))?;
|
||||
|
||||
Reference in New Issue
Block a user