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