From 2ac438a82dff381d3089f5340106791f215f8e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 2 May 2016 16:12:01 +0200 Subject: [PATCH] Exposing default extra data --- rpc/src/v1/impls/ethcore.rs | 6 ++++++ rpc/src/v1/traits/ethcore.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index 492f5810c..7b02c7f78 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -17,6 +17,7 @@ //! Ethcore-specific rpc implementation. use util::{U256, Address, RotatingLogger}; use util::network_settings::NetworkSettings; +use util::misc::version_data; use std::sync::{Arc, Weak}; use std::ops::Deref; use std::collections::BTreeMap; @@ -129,4 +130,9 @@ impl Ethcore for EthcoreClient where M: MinerService + 'static { map.insert("port".to_owned(), Value::U64(self.settings.rpc_port as u64)); Ok(Value::Object(map)) } + + fn default_extra_data(&self, _params: Params) -> Result { + let version = version_data(); + to_value(&version) + } } diff --git a/rpc/src/v1/traits/ethcore.rs b/rpc/src/v1/traits/ethcore.rs index 9aab17b4c..2a2159bd9 100644 --- a/rpc/src/v1/traits/ethcore.rs +++ b/rpc/src/v1/traits/ethcore.rs @@ -69,6 +69,10 @@ pub trait Ethcore: Sized + Send + Sync + 'static { /// Returns node name fn node_name(&self, _: Params) -> Result { rpc_unimplemented!() } + /// Returns default extra data + fn default_extra_data(&self, _: Params) -> Result { rpc_unimplemented!() } + + /// Should be used to convert object to io delegate. fn to_delegate(self) -> IoDelegate { 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_rpcSettings", Ethcore::rpc_settings); delegate.add_method("ethcore_nodeName", Ethcore::node_name); + delegate.add_method("ethcore_defaultExtraData", Ethcore::default_extra_data); delegate }