forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RPCs for versioning (paritytech#175)
* RPCs for versioning. * Build fix for bad merge. * Add system_name RPC * Fix tests. * Fix demo build. * Remove BadFormat.
- Loading branch information
Showing
10 changed files
with
202 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "polkadot-cli" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
description = "Polkadot node implementation in Rust." | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,4 @@ pub mod author; | |
pub mod chain; | ||
pub mod metadata; | ||
pub mod state; | ||
pub mod system; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate. | ||
|
||
// Substrate is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Substrate is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! System RPC module errors. | ||
use rpc; | ||
|
||
error_chain! { | ||
errors { | ||
/// Not implemented yet | ||
Unimplemented { | ||
description("not yet implemented"), | ||
display("Method Not Implemented"), | ||
} | ||
} | ||
} | ||
|
||
impl From<Error> for rpc::Error { | ||
fn from(e: Error) -> Self { | ||
match e { | ||
Error(ErrorKind::Unimplemented, _) => rpc::Error { | ||
code: rpc::ErrorCode::ServerError(-1), | ||
message: "Not implemented yet".into(), | ||
data: None, | ||
}, | ||
_ => rpc::Error::internal_error(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate. | ||
|
||
// Substrate is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Substrate is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Substrate system API. | ||
pub mod error; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
use self::error::Result; | ||
|
||
build_rpc_trait! { | ||
/// Substrate system RPC API | ||
pub trait SystemApi { | ||
/// Get the node's implementation name. Plain old string. | ||
#[rpc(name = "system_name")] | ||
fn system_name(&self) -> Result<String>; | ||
|
||
/// Get the node implementation's version. Should be a semver string. | ||
#[rpc(name = "system_version")] | ||
fn system_version(&self) -> Result<String>; | ||
|
||
/// Get the chain's type. Given as a string identifier. | ||
#[rpc(name = "system_chain")] | ||
fn system_chain(&self) -> Result<String>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Substrate. | ||
|
||
// Substrate is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Substrate is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use super::*; | ||
use super::error::*; | ||
|
||
impl SystemApi for () { | ||
fn system_name(&self) -> Result<String> { | ||
Ok("testclient".into()) | ||
} | ||
fn system_version(&self) -> Result<String> { | ||
Ok("0.2.0".into()) | ||
} | ||
fn system_chain(&self) -> Result<String> { | ||
Ok("testchain".into()) | ||
} | ||
} | ||
|
||
#[test] | ||
fn system_name_works() { | ||
assert_eq!( | ||
SystemApi::system_name(&()).unwrap(), | ||
"testclient".to_owned() | ||
); | ||
} | ||
|
||
#[test] | ||
fn system_version_works() { | ||
assert_eq!( | ||
SystemApi::system_version(&()).unwrap(), | ||
"0.2.0".to_owned() | ||
); | ||
} | ||
|
||
#[test] | ||
fn system_chain_works() { | ||
assert_eq!( | ||
SystemApi::system_chain(&()).unwrap(), | ||
"testchain".to_owned() | ||
); | ||
} |