RPCs for reserved peers (#4423)

* RPC forwarders for adding reserved peers

* implement service side of reserved-peer RPCs

* Clean up unnecessary format! invocation

Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* add some tests for the new RPC methods

* remove redundant `data` field

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
Robert Habermeier
2019-12-18 14:12:15 +01:00
committed by GitHub
parent 637d95e5ea
commit da87c3c1e3
6 changed files with 125 additions and 3 deletions
@@ -28,6 +28,8 @@ pub enum Error {
/// Provided block range couldn't be resolved to a list of blocks.
#[display(fmt = "Node is not fully functional: {}", _0)]
NotHealthy(Health),
/// Peer argument is malformatted.
MalformattedPeerArg(String),
}
impl std::error::Error for Error {}
@@ -43,6 +45,11 @@ impl From<Error> for rpc::Error {
message: format!("{}", e),
data: serde_json::to_value(h).ok(),
},
Error::MalformattedPeerArg(ref e) => rpc::Error {
code :rpc::ErrorCode::ServerError(BASE_ERROR + 2),
message: e.clone(),
data: None,
}
}
}
}