Exposing default extra data

This commit is contained in:
Tomasz Drwięga 2016-05-02 16:12:01 +02:00
parent c34e3535e0
commit 2ac438a82d
2 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,7 @@
//! Ethcore-specific rpc implementation. //! Ethcore-specific rpc implementation.
use util::{U256, Address, RotatingLogger}; use util::{U256, Address, RotatingLogger};
use util::network_settings::NetworkSettings; use util::network_settings::NetworkSettings;
use util::misc::version_data;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use std::ops::Deref; use std::ops::Deref;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -129,4 +130,9 @@ impl<M> Ethcore for EthcoreClient<M> where M: MinerService + 'static {
map.insert("port".to_owned(), Value::U64(self.settings.rpc_port as u64)); map.insert("port".to_owned(), Value::U64(self.settings.rpc_port as u64));
Ok(Value::Object(map)) Ok(Value::Object(map))
} }
fn default_extra_data(&self, _params: Params) -> Result<Value, Error> {
let version = version_data();
to_value(&version)
}
} }

View File

@ -69,6 +69,10 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
/// Returns node name /// Returns node name
fn node_name(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() } fn node_name(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
/// Returns default extra data
fn default_extra_data(&self, _: Params) -> Result<Value, Error> { rpc_unimplemented!() }
/// Should be used to convert object to io delegate. /// Should be used to convert object to io delegate.
fn to_delegate(self) -> IoDelegate<Self> { fn to_delegate(self) -> IoDelegate<Self> {
let mut delegate = IoDelegate::new(Arc::new(self)); let mut delegate = IoDelegate::new(Arc::new(self));
@ -89,6 +93,7 @@ pub trait Ethcore: Sized + Send + Sync + 'static {
delegate.add_method("ethcore_netPort", Ethcore::net_port); delegate.add_method("ethcore_netPort", Ethcore::net_port);
delegate.add_method("ethcore_rpcSettings", Ethcore::rpc_settings); delegate.add_method("ethcore_rpcSettings", Ethcore::rpc_settings);
delegate.add_method("ethcore_nodeName", Ethcore::node_name); delegate.add_method("ethcore_nodeName", Ethcore::node_name);
delegate.add_method("ethcore_defaultExtraData", Ethcore::default_extra_data);
delegate delegate
} }