parent
cf8f27ce0f
commit
36d17d5c28
@ -41,6 +41,7 @@ mod codes {
|
||||
pub const ACCOUNT_ERROR: i64 = -32023;
|
||||
pub const SIGNER_DISABLED: i64 = -32030;
|
||||
pub const DAPPS_DISABLED: i64 = -32031;
|
||||
pub const NETWORK_DISABLED: i64 = -32035;
|
||||
pub const REQUEST_REJECTED: i64 = -32040;
|
||||
pub const REQUEST_REJECTED_LIMIT: i64 = -32041;
|
||||
pub const REQUEST_NOT_FOUND: i64 = -32042;
|
||||
@ -185,6 +186,14 @@ pub fn dapps_disabled() -> Error {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn network_disabled() -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::NETWORK_DISABLED),
|
||||
message: "Network is disabled or not yet up.".into(),
|
||||
data: None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn encryption_error<T: fmt::Debug>(error: T) -> Error {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::ENCRYPTION_ERROR),
|
||||
|
@ -353,4 +353,8 @@ impl<C, M, S: ?Sized, F> Ethcore for EthcoreClient<C, M, S, F> where
|
||||
Mode::Active => "active",
|
||||
}.into())
|
||||
}
|
||||
|
||||
fn enode(&self) -> Result<String, Error> {
|
||||
take_weak!(self.sync).enode().ok_or_else(errors::network_disabled)
|
||||
}
|
||||
}
|
||||
|
@ -93,5 +93,9 @@ impl SyncProvider for TestSyncProvider {
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
fn enode(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,5 +133,9 @@ build_rpc_trait! {
|
||||
/// Get the mode. Results one of: "active", "passive", "dark", "off".
|
||||
#[rpc(name = "ethcore_mode")]
|
||||
fn mode(&self) -> Result<String, Error>;
|
||||
|
||||
/// Get the enode of this node.
|
||||
#[rpc(name = "ethcore_enode")]
|
||||
fn enode(&self) -> Result<String, Error>;
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,9 @@ pub trait SyncProvider: Send + Sync {
|
||||
|
||||
/// Get peers information
|
||||
fn peers(&self) -> Vec<PeerInfo>;
|
||||
|
||||
/// Get the enode if available.
|
||||
fn enode(&self) -> Option<String>;
|
||||
}
|
||||
|
||||
/// Peer connection information
|
||||
@ -143,6 +146,10 @@ impl SyncProvider for EthSync {
|
||||
self.handler.sync.write().peers(&sync_io)
|
||||
}).unwrap_or(Vec::new())
|
||||
}
|
||||
|
||||
fn enode(&self) -> Option<String> {
|
||||
self.network.external_url()
|
||||
}
|
||||
}
|
||||
|
||||
struct SyncProtocolHandler {
|
||||
|
Loading…
Reference in New Issue
Block a user