ethsync: optional ipc codegen
This commit is contained in:
parent
2e87e31157
commit
efd66f566d
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -462,6 +462,8 @@ version = "1.5.0"
|
||||
dependencies = [
|
||||
"ethcore 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-network 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -55,7 +55,7 @@ winapi = "0.2"
|
||||
daemonize = "0.2"
|
||||
|
||||
[features]
|
||||
default = ["ui-precompiled", "light"]
|
||||
default = ["ui-precompiled"]
|
||||
|
||||
ui = [
|
||||
"dapps",
|
||||
@ -80,7 +80,6 @@ ethstore-cli = ["ethcore/ethstore-cli"]
|
||||
evm-debug = ["ethcore/evm-debug"]
|
||||
evm-debug-tests = ["ethcore/evm-debug-tests"]
|
||||
slow-blocks = ["ethcore/slow-blocks"]
|
||||
light = ["ethcore/light", "ethsync/light"]
|
||||
|
||||
[[bin]]
|
||||
path = "parity/main.rs"
|
||||
|
@ -58,6 +58,5 @@ dev = ["clippy"]
|
||||
default = []
|
||||
benches = []
|
||||
ipc = []
|
||||
light = []
|
||||
ethkey-cli = ["ethkey/cli"]
|
||||
ethstore-cli = ["ethstore/cli"]
|
||||
|
@ -12,7 +12,7 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
log = "0.3"
|
||||
ethcore = { path = "..", features = ["light"] }
|
||||
ethcore = { path = ".."}
|
||||
ethcore-util = { path = "../../util" }
|
||||
ethcore-network = { path = "../../util/network" }
|
||||
ethcore-io = { path = "../../util/io" }
|
||||
@ -22,4 +22,4 @@ time = "0.1"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
ipc = ["ethcore/ipc", "ethcore-ipc", "ethcore-ipc-codegen"]
|
||||
ipc = ["ethcore-ipc", "ethcore-ipc-codegen"]
|
@ -1377,7 +1377,6 @@ impl MayPanic for Client {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "light")]
|
||||
impl ::client::ProvingBlockChainClient for Client {
|
||||
fn prove_storage(&self, key1: H256, key2: H256, from_level: u32, id: BlockID) -> Vec<Bytes> {
|
||||
self.state_at(id)
|
||||
|
@ -29,7 +29,6 @@ pub use self::test_client::{TestBlockChainClient, EachBlockWith};
|
||||
pub use self::chain_notify::ChainNotify;
|
||||
pub use self::traits::{BlockChainClient, MiningBlockChainClient};
|
||||
|
||||
#[cfg(feature = "light")]
|
||||
pub use self::traits::ProvingBlockChainClient;
|
||||
|
||||
pub use types::ids::*;
|
||||
|
@ -278,7 +278,6 @@ pub trait MiningBlockChainClient: BlockChainClient {
|
||||
}
|
||||
|
||||
/// Extended client interface for providing proofs of the state.
|
||||
#[cfg(feature = "light")]
|
||||
pub trait ProvingBlockChainClient: BlockChainClient {
|
||||
/// Prove account storage at a specific block id.
|
||||
///
|
||||
|
@ -32,7 +32,6 @@ use state_db::StateDB;
|
||||
|
||||
use util::*;
|
||||
|
||||
#[cfg(feature = "light")]
|
||||
use util::trie::recorder::{Recorder, BasicRecorder as TrieRecorder};
|
||||
|
||||
mod account;
|
||||
@ -764,7 +763,6 @@ impl State {
|
||||
}
|
||||
|
||||
// LES state proof implementations.
|
||||
#[cfg(feature = "light")]
|
||||
impl State {
|
||||
/// Prove an account's existence or nonexistence in the state trie.
|
||||
/// Returns a merkle proof of the account's trie node with all nodes before `from_level`
|
||||
|
@ -15,7 +15,7 @@ ethcore-ipc-codegen = { path = "../ipc/codegen" }
|
||||
ethcore-util = { path = "../util" }
|
||||
ethcore-network = { path = "../util/network" }
|
||||
ethcore-io = { path = "../util/io" }
|
||||
ethcore-light = { path = "../ethcore/light", optional = true }
|
||||
ethcore-light = { path = "../ethcore/light"}
|
||||
ethcore = { path = "../ethcore" }
|
||||
rlp = { path = "../util/rlp" }
|
||||
clippy = { version = "0.0.103", optional = true}
|
||||
@ -30,7 +30,6 @@ ethcore-ipc-nano = { path = "../ipc/nano" }
|
||||
parking_lot = "0.3"
|
||||
|
||||
[features]
|
||||
default = ["ipc"]
|
||||
default = []
|
||||
dev = ["clippy", "ethcore/dev", "ethcore-util/dev"]
|
||||
light = ["ethcore-light"]
|
||||
ipc = []
|
||||
ipc = ["ethcore-light/ipc"]
|
||||
|
@ -85,14 +85,18 @@ pub trait SyncProvider: Send + Sync {
|
||||
}
|
||||
|
||||
/// Transaction stats
|
||||
#[derive(Debug, Binary)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "ipc", derive(Binary))]
|
||||
pub struct TransactionStats {
|
||||
/// Block number where this TX was first seen.
|
||||
pub first_seen: u64,
|
||||
/// Peers it was propagated to.
|
||||
pub propagated_to: BTreeMap<H512, usize>,
|
||||
}
|
||||
|
||||
/// Peer connection information
|
||||
#[derive(Debug, Binary)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "ipc", derive(Binary))]
|
||||
pub struct PeerInfo {
|
||||
/// Public node id
|
||||
pub id: Option<String>,
|
||||
@ -120,8 +124,6 @@ pub struct EthSync {
|
||||
handler: Arc<SyncProtocolHandler>,
|
||||
/// The main subprotocol name
|
||||
subprotocol_name: [u8; 3],
|
||||
/// Configuration
|
||||
config: NetworkConfiguration,
|
||||
}
|
||||
|
||||
impl EthSync {
|
||||
@ -138,14 +140,13 @@ impl EthSync {
|
||||
overlay: RwLock::new(HashMap::new()),
|
||||
}),
|
||||
subprotocol_name: config.subprotocol_name,
|
||||
config: network_config,
|
||||
});
|
||||
|
||||
Ok(sync)
|
||||
}
|
||||
}
|
||||
|
||||
#[ipc(client_ident="SyncClient")]
|
||||
#[cfg_attr(feature = "ipc", ipc(client_ident="SyncClient"))]
|
||||
impl SyncProvider for EthSync {
|
||||
/// Get sync status
|
||||
fn status(&self) -> SyncStatus {
|
||||
@ -279,7 +280,7 @@ pub trait ManageNetwork : Send + Sync {
|
||||
}
|
||||
|
||||
|
||||
#[ipc(client_ident="NetworkManagerClient")]
|
||||
#[cfg_attr(feature = "ipc", ipc(client_ident="NetworkManagerClient"))]
|
||||
impl ManageNetwork for EthSync {
|
||||
fn accept_unreserved_peers(&self) {
|
||||
self.network.set_non_reserved_mode(NonReservedPeerMode::Accept);
|
||||
@ -315,7 +316,8 @@ impl ManageNetwork for EthSync {
|
||||
}
|
||||
|
||||
/// IP fiter
|
||||
#[derive(Binary, Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "ipc", derive(Binary))]
|
||||
pub enum AllowIP {
|
||||
/// Connect to any address
|
||||
All,
|
||||
@ -337,7 +339,8 @@ impl AllowIP {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Binary, Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "ipc", derive(Binary))]
|
||||
/// Network service configuration
|
||||
pub struct NetworkConfiguration {
|
||||
/// Directory path to store general network configuration. None means nothing will be saved
|
||||
@ -375,26 +378,18 @@ pub struct NetworkConfiguration {
|
||||
}
|
||||
|
||||
impl NetworkConfiguration {
|
||||
/// Create a new default config.
|
||||
pub fn new() -> Self {
|
||||
From::from(BasicNetworkConfiguration::new())
|
||||
}
|
||||
|
||||
/// Create a new local config.
|
||||
pub fn new_local() -> Self {
|
||||
From::from(BasicNetworkConfiguration::new_local())
|
||||
}
|
||||
|
||||
fn validate(&self) -> Result<(), AddrParseError> {
|
||||
if let Some(ref addr) = self.listen_address {
|
||||
try!(SocketAddr::from_str(&addr));
|
||||
}
|
||||
if let Some(ref addr) = self.public_address {
|
||||
try!(SocketAddr::from_str(&addr));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Attempt to convert this config into a BasicNetworkConfiguration.
|
||||
pub fn into_basic(self) -> Result<BasicNetworkConfiguration, AddrParseError> {
|
||||
|
||||
Ok(BasicNetworkConfiguration {
|
||||
config_path: self.config_path,
|
||||
net_config_path: self.net_config_path,
|
||||
@ -447,9 +442,14 @@ impl From<BasicNetworkConfiguration> for NetworkConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Binary, Clone)]
|
||||
/// Configuration for IPC service.
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "ipc", derive(Binary))]
|
||||
pub struct ServiceConfiguration {
|
||||
/// Sync config.
|
||||
pub sync: SyncConfig,
|
||||
/// Network configuration.
|
||||
pub net: NetworkConfiguration,
|
||||
/// IPC path.
|
||||
pub io_path: String,
|
||||
}
|
||||
|
@ -37,10 +37,8 @@ extern crate semver;
|
||||
extern crate parking_lot;
|
||||
extern crate rlp;
|
||||
|
||||
#[cfg(feature = "light")]
|
||||
extern crate ethcore_light as light;
|
||||
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
@ -60,12 +58,16 @@ mod transactions_stats;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
#[cfg(feature = "ipc")]
|
||||
mod api {
|
||||
#![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues
|
||||
include!(concat!(env!("OUT_DIR"), "/api.rs"));
|
||||
}
|
||||
|
||||
pub use api::{EthSync, SyncProvider, SyncClient, NetworkManagerClient, ManageNetwork, SyncConfig,
|
||||
#[cfg(not(feature = "ipc"))]
|
||||
mod api;
|
||||
|
||||
pub use api::{EthSync, SyncProvider, ManageNetwork, SyncConfig,
|
||||
ServiceConfiguration, NetworkConfiguration, PeerInfo, AllowIP, TransactionStats};
|
||||
pub use chain::{SyncStatus, SyncState};
|
||||
pub use network::{is_valid_node_url, NonReservedPeerMode, NetworkError};
|
||||
|
@ -17,4 +17,6 @@
|
||||
pub mod helpers;
|
||||
pub mod snapshot;
|
||||
mod chain;
|
||||
|
||||
#[cfg(feature = "ipc")]
|
||||
mod rpc;
|
||||
|
Loading…
Reference in New Issue
Block a user