Health endpoint (#9847)
* Health endpoint. * Fix chain handling. * Update to latest json-rpc. * Change dev chain detection. * Fix test.
This commit is contained in:
committed by
Niklas Adolfsson
parent
f6dcca3ebb
commit
f680eacdf2
@@ -52,6 +52,7 @@ mod codes {
|
||||
pub const ENCODING_ERROR: i64 = -32058;
|
||||
pub const FETCH_ERROR: i64 = -32060;
|
||||
pub const NO_LIGHT_PEERS: i64 = -32065;
|
||||
pub const NO_PEERS: i64 = -32066;
|
||||
pub const DEPRECATED: i64 = -32070;
|
||||
}
|
||||
|
||||
@@ -500,3 +501,15 @@ pub fn on_demand_others(err: &OnDemandError) -> Error {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn status_error(has_peers: bool) -> Error {
|
||||
if has_peers {
|
||||
no_work()
|
||||
} else {
|
||||
Error {
|
||||
code: ErrorCode::ServerError(codes::NO_PEERS),
|
||||
message: "Node is not connected to any peers.".into(),
|
||||
data: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ pub struct NetworkSettings {
|
||||
pub name: String,
|
||||
/// Name of the chain we are connected to
|
||||
pub chain: String,
|
||||
/// Is development chain
|
||||
pub is_dev_chain: bool,
|
||||
/// Networking port
|
||||
pub network_port: u16,
|
||||
/// Is JSON-RPC server enabled?
|
||||
@@ -38,6 +40,7 @@ impl Default for NetworkSettings {
|
||||
NetworkSettings {
|
||||
name: "".into(),
|
||||
chain: "foundation".into(),
|
||||
is_dev_chain: false,
|
||||
network_port: 30303,
|
||||
rpc_enabled: true,
|
||||
rpc_interface: "127.0.0.1".into(),
|
||||
|
||||
Reference in New Issue
Block a user