@@ -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>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user