CLI options for light client
This commit is contained in:
parent
dd1a3fc60a
commit
a9d75e2223
@ -38,7 +38,7 @@ warp = true
|
||||
allow_ips = "all"
|
||||
snapshot_peers = 0
|
||||
max_pending_peers = 64
|
||||
serve_light = true
|
||||
no_serve_light = false
|
||||
|
||||
reserved_only = false
|
||||
reserved_peers = "./path_to_file"
|
||||
|
@ -93,6 +93,7 @@ usage! {
|
||||
flag_chain: String = "foundation", or |c: &Config| otry!(c.parity).chain.clone(),
|
||||
flag_keys_path: String = "$BASE/keys", or |c: &Config| otry!(c.parity).keys_path.clone(),
|
||||
flag_identity: String = "", or |c: &Config| otry!(c.parity).identity.clone(),
|
||||
flag_light: bool = false, or |c: &Config| otry!(c.parity).light,
|
||||
|
||||
// -- Account Options
|
||||
flag_unlock: Option<String> = None,
|
||||
@ -148,6 +149,8 @@ usage! {
|
||||
flag_reserved_only: bool = false,
|
||||
or |c: &Config| otry!(c.network).reserved_only.clone(),
|
||||
flag_no_ancient_blocks: bool = false, or |_| None,
|
||||
flag_no_serve_light: bool = false,
|
||||
or |c: &Config| otry!(c.network).no_serve_light.clone(),
|
||||
|
||||
// -- API and Console Options
|
||||
// RPC
|
||||
@ -372,6 +375,7 @@ struct Operating {
|
||||
db_path: Option<String>,
|
||||
keys_path: Option<String>,
|
||||
identity: Option<String>,
|
||||
light: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
||||
@ -407,6 +411,7 @@ struct Network {
|
||||
node_key: Option<String>,
|
||||
reserved_peers: Option<String>,
|
||||
reserved_only: Option<bool>,
|
||||
no_serve_light: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
||||
@ -630,6 +635,7 @@ mod tests {
|
||||
flag_db_path: Some("$HOME/.parity/chains".into()),
|
||||
flag_keys_path: "$HOME/.parity/keys".into(),
|
||||
flag_identity: "".into(),
|
||||
flag_light: false,
|
||||
|
||||
// -- Account Options
|
||||
flag_unlock: Some("0xdeadbeefcafe0000000000000000000000000000".into()),
|
||||
@ -660,6 +666,7 @@ mod tests {
|
||||
flag_reserved_peers: Some("./path_to_file".into()),
|
||||
flag_reserved_only: false,
|
||||
flag_no_ancient_blocks: false,
|
||||
flag_no_serve_light: false,
|
||||
|
||||
// -- API and Console Options
|
||||
// RPC
|
||||
@ -832,6 +839,7 @@ mod tests {
|
||||
db_path: None,
|
||||
keys_path: None,
|
||||
identity: None,
|
||||
light: None,
|
||||
}),
|
||||
account: Some(Account {
|
||||
unlock: Some(vec!["0x1".into(), "0x2".into(), "0x3".into()]),
|
||||
@ -861,6 +869,7 @@ mod tests {
|
||||
node_key: None,
|
||||
reserved_peers: Some("./path/to/reserved_peers".into()),
|
||||
reserved_only: Some(true),
|
||||
no_serve_light: None,
|
||||
}),
|
||||
rpc: Some(Rpc {
|
||||
disable: Some(true),
|
||||
|
@ -67,6 +67,10 @@ Operating Options:
|
||||
--keys-path PATH Specify the path for JSON key files to be found
|
||||
(default: {flag_keys_path}).
|
||||
--identity NAME Specify your node's name. (default: {flag_identity})
|
||||
--light Experimental: run in light client mode. Light clients
|
||||
synchronize a bare minimum of data and fetch necessary
|
||||
data on-demand from the network. Much lower in storage,
|
||||
potentially higher in bandwidth. (default: {flag_light})
|
||||
|
||||
Account Options:
|
||||
--unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution.
|
||||
@ -126,6 +130,7 @@ Networking Options:
|
||||
--max-pending-peers NUM Allow up to NUM pending connections. (default: {flag_max_pending_peers})
|
||||
--no-ancient-blocks Disable downloading old blocks after snapshot restoration
|
||||
or warp sync. (default: {flag_no_ancient_blocks})
|
||||
--no-serve-light Disable serving of light peers. (default: {flag_no_serve_light})
|
||||
|
||||
API and Console Options:
|
||||
--no-jsonrpc Disable the JSON-RPC API server. (default: {flag_no_jsonrpc})
|
||||
|
@ -375,6 +375,8 @@ impl Configuration {
|
||||
check_seal: !self.args.flag_no_seal_check,
|
||||
download_old_blocks: !self.args.flag_no_ancient_blocks,
|
||||
verifier_settings: verifier_settings,
|
||||
serve_light: !self.args.flag_no_serve_light,
|
||||
light: self.args.flag_light,
|
||||
};
|
||||
Cmd::Run(run_cmd)
|
||||
};
|
||||
@ -1194,6 +1196,8 @@ mod tests {
|
||||
check_seal: true,
|
||||
download_old_blocks: true,
|
||||
verifier_settings: Default::default(),
|
||||
serve_light: true,
|
||||
light: false,
|
||||
};
|
||||
expected.secretstore_conf.enabled = cfg!(feature = "secretstore");
|
||||
assert_eq!(conf.into_command().unwrap().cmd, Cmd::Run(expected));
|
||||
|
@ -107,6 +107,8 @@ pub struct RunCmd {
|
||||
pub check_seal: bool,
|
||||
pub download_old_blocks: bool,
|
||||
pub verifier_settings: VerifierSettings,
|
||||
pub serve_light: bool,
|
||||
pub light: bool,
|
||||
}
|
||||
|
||||
pub fn open_ui(dapps_conf: &dapps::Configuration, signer_conf: &signer::Configuration) -> Result<(), String> {
|
||||
@ -248,6 +250,7 @@ pub fn execute(cmd: RunCmd, can_restart: bool, logger: Arc<RotatingLogger>) -> R
|
||||
sync_config.fork_block = spec.fork_block();
|
||||
sync_config.warp_sync = cmd.warp_sync;
|
||||
sync_config.download_old_blocks = cmd.download_old_blocks;
|
||||
sync_config.serve_light = cmd.serve_light;
|
||||
|
||||
let passwords = passwords_from_files(&cmd.acc_conf.password_files)?;
|
||||
|
||||
|
@ -83,7 +83,7 @@ impl SyncProvider for TestSyncProvider {
|
||||
difficulty: Some(40.into()),
|
||||
head: 50.into(),
|
||||
}),
|
||||
les_info: None,
|
||||
pip_info: None,
|
||||
},
|
||||
PeerInfo {
|
||||
id: None,
|
||||
@ -96,7 +96,7 @@ impl SyncProvider for TestSyncProvider {
|
||||
difficulty: None,
|
||||
head: 60.into()
|
||||
}),
|
||||
les_info: None,
|
||||
pip_info: None,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ pub use self::receipt::Receipt;
|
||||
pub use self::rpc_settings::RpcSettings;
|
||||
pub use self::sync::{
|
||||
SyncStatus, SyncInfo, Peers, PeerInfo, PeerNetworkInfo, PeerProtocolsInfo,
|
||||
TransactionStats, ChainStatus, EthProtocolInfo, LesProtocolInfo,
|
||||
TransactionStats, ChainStatus, EthProtocolInfo, PipProtocolInfo,
|
||||
};
|
||||
pub use self::trace::{LocalizedTrace, TraceResults};
|
||||
pub use self::trace_filter::TraceFilter;
|
||||
|
@ -83,8 +83,8 @@ pub struct PeerNetworkInfo {
|
||||
pub struct PeerProtocolsInfo {
|
||||
/// Ethereum protocol information
|
||||
pub eth: Option<EthProtocolInfo>,
|
||||
/// LES protocol information.
|
||||
pub les: Option<LesProtocolInfo>,
|
||||
/// PIP protocol information.
|
||||
pub pip: Option<PipProtocolInfo>,
|
||||
}
|
||||
|
||||
/// Peer Ethereum protocol information
|
||||
@ -108,10 +108,10 @@ impl From<ethsync::EthProtocolInfo> for EthProtocolInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/// Peer LES protocol information
|
||||
/// Peer PIP protocol information
|
||||
#[derive(Default, Debug, Serialize)]
|
||||
pub struct LesProtocolInfo {
|
||||
/// Negotiated LES protocol version
|
||||
pub struct PipProtocolInfo {
|
||||
/// Negotiated PIP protocol version
|
||||
pub version: u32,
|
||||
/// Peer total difficulty
|
||||
pub difficulty: U256,
|
||||
@ -119,9 +119,9 @@ pub struct LesProtocolInfo {
|
||||
pub head: String,
|
||||
}
|
||||
|
||||
impl From<ethsync::LesProtocolInfo> for LesProtocolInfo {
|
||||
fn from(info: ethsync::LesProtocolInfo) -> Self {
|
||||
LesProtocolInfo {
|
||||
impl From<ethsync::PipProtocolInfo> for PipProtocolInfo {
|
||||
fn from(info: ethsync::PipProtocolInfo) -> Self {
|
||||
PipProtocolInfo {
|
||||
version: info.version,
|
||||
difficulty: info.difficulty.into(),
|
||||
head: info.head.hex(),
|
||||
@ -171,7 +171,7 @@ impl From<SyncPeerInfo> for PeerInfo {
|
||||
},
|
||||
protocols: PeerProtocolsInfo {
|
||||
eth: p.eth_info.map(Into::into),
|
||||
les: p.les_info.map(Into::into),
|
||||
pip: p.pip_info.map(Into::into),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ pub struct PeerInfo {
|
||||
/// Eth protocol info.
|
||||
pub eth_info: Option<EthProtocolInfo>,
|
||||
/// Light protocol info.
|
||||
pub les_info: Option<LesProtocolInfo>,
|
||||
pub pip_info: Option<PipProtocolInfo>,
|
||||
}
|
||||
|
||||
/// Ethereum protocol info.
|
||||
@ -141,10 +141,10 @@ pub struct EthProtocolInfo {
|
||||
pub difficulty: Option<U256>,
|
||||
}
|
||||
|
||||
/// LES protocol info.
|
||||
/// PIP protocol info.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "ipc", derive(Binary))]
|
||||
pub struct LesProtocolInfo {
|
||||
pub struct PipProtocolInfo {
|
||||
/// Protocol version
|
||||
pub version: u32,
|
||||
/// SHA3 of peer best block hash
|
||||
@ -153,9 +153,9 @@ pub struct LesProtocolInfo {
|
||||
pub difficulty: U256,
|
||||
}
|
||||
|
||||
impl From<light_net::Status> for LesProtocolInfo {
|
||||
impl From<light_net::Status> for PipProtocolInfo {
|
||||
fn from(status: light_net::Status) -> Self {
|
||||
LesProtocolInfo {
|
||||
PipProtocolInfo {
|
||||
version: status.protocol_version,
|
||||
head: status.head_hash,
|
||||
difficulty: status.head_td,
|
||||
@ -184,7 +184,7 @@ pub struct EthSync {
|
||||
network: NetworkService,
|
||||
/// Main (eth/par) protocol handler
|
||||
eth_handler: Arc<SyncProtocolHandler>,
|
||||
/// Light (les) protocol handler
|
||||
/// Light (pip) protocol handler
|
||||
light_proto: Option<Arc<LightProtocol>>,
|
||||
/// The main subprotocol name
|
||||
subprotocol_name: [u8; 3],
|
||||
@ -264,7 +264,7 @@ impl SyncProvider for EthSync {
|
||||
remote_address: session_info.remote_address,
|
||||
local_address: session_info.local_address,
|
||||
eth_info: eth_sync.peer_info(&peer_id),
|
||||
les_info: light_proto.as_ref().and_then(|lp| lp.peer_status(&peer_id)).map(Into::into),
|
||||
pip_info: light_proto.as_ref().and_then(|lp| lp.peer_status(&peer_id)).map(Into::into),
|
||||
})
|
||||
}).collect()
|
||||
}).unwrap_or_else(Vec::new)
|
||||
@ -408,7 +408,7 @@ impl ChainNotify for EthSync {
|
||||
}
|
||||
}
|
||||
|
||||
/// LES event handler.
|
||||
/// PIP event handler.
|
||||
/// Simply queues transactions from light client peers.
|
||||
struct TxRelay(Arc<BlockChainClient>);
|
||||
|
||||
@ -786,7 +786,7 @@ impl LightSyncProvider for LightSync {
|
||||
remote_address: session_info.remote_address,
|
||||
local_address: session_info.local_address,
|
||||
eth_info: None,
|
||||
les_info: self.proto.peer_status(&peer_id).map(Into::into),
|
||||
pip_info: self.proto.peer_status(&peer_id).map(Into::into),
|
||||
})
|
||||
}).collect()
|
||||
}).unwrap_or_else(Vec::new)
|
||||
|
Loading…
Reference in New Issue
Block a user