Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.6k
RPCs for versioning#175
Uh oh!
There was an error while loading. Please reload this page.
RPCs for versioning #175
Changes from all commits
5a61b67d443f30d580278e1ab201471e6d0708c08ad1fb5a7File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| 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; | ||
| 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 | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think the errors are needed at all. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i removed | ||
| 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(), | ||
| } | ||
| } | ||
| } | ||
| 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>; | ||
| } | ||
| } |
| 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() | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't that be derived?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sadly not since the
transaction_pool::Optionsdoesn't deriveCloneand it's in a different repo so can't be fixed in this PR.