-
Notifications
You must be signed in to change notification settings - Fork 2.7k
RPCs for versioning #175
RPCs for versioning #175
Changes from 2 commits
5a61b67
d443f30
d580278
e1ab201
471e6d0
708c08a
d1fb5a7
File filter
Filter by extension
Conversations
Jump to
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.
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." | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ pub use network::NetworkConfiguration; | |
|
||
/// The chain specification (this should eventually be replaced by a more general JSON-based chain | ||
/// specification). | ||
#[derive(Clone)] | ||
pub enum ChainSpec { | ||
/// Whatever the current runtime is, with just Alice as an auth. | ||
Development, | ||
|
@@ -62,3 +63,21 @@ impl Default for Configuration { | |
} | ||
} | ||
} | ||
|
||
impl Clone for Configuration { | ||
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. Can't that be derived? 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. sadly not since the |
||
fn clone(&self) -> Configuration { | ||
Configuration { | ||
roles: self.roles.clone(), | ||
transaction_pool: transaction_pool::Options { | ||
max_count: self.transaction_pool.max_count.clone(), | ||
max_mem_usage: self.transaction_pool.max_mem_usage.clone(), | ||
max_per_sender: self.transaction_pool.max_per_sender.clone(), | ||
}, | ||
network: self.network.clone(), | ||
keystore_path: self.keystore_path.clone(), | ||
database_path: self.database_path.clone(), | ||
keys: self.keys.clone(), | ||
chain_spec: self.chain_spec.clone(), | ||
} | ||
} | ||
} |
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,47 @@ | ||
// 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 | ||
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. 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"), | ||
} | ||
/// Invalid format | ||
InvalidFormat { | ||
description("invalid format"), | ||
display("Invalid format for the extrinsic data"), | ||
} | ||
} | ||
} | ||
|
||
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,37 @@ | ||
// 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 system's version. Given as a semver string. | ||
#[rpc(name = "system_version")] | ||
fn system_version(&self) -> Result<String>; | ||
|
||
/// Get the chain's type. Given as a semver string. | ||
#[rpc(name = "system_chain")] | ||
fn system_chain(&self) -> Result<String>; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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_version(&self) -> Result<String> { | ||
Ok("0.2.0".into()) | ||
} | ||
fn system_chain(&self) -> Result<String> { | ||
Ok("test".into()) | ||
} | ||
} | ||
|
||
#[test] | ||
fn system_version_works() { | ||
assert_matches!( | ||
AuthorApi::system_version(&()), | ||
Ok("0.2.0".to_owned()) | ||
); | ||
} | ||
|
||
#[test] | ||
fn system_chain_works() { | ||
assert_matches!( | ||
AuthorApi::system_chain(&()), | ||
Ok("test".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.
It would be nice to have a
system_name
as well. (i.e. the JS client version don't match up with these, however the version + name is a proper identifier)