rpc net methods returns real peer count && protocol version
This commit is contained in:
@@ -1,21 +1,29 @@
|
||||
//! Net rpc implementation.
|
||||
use std::sync::Arc;
|
||||
use jsonrpc_core::*;
|
||||
use ethcore::sync::EthSync;
|
||||
use v1::traits::Net;
|
||||
|
||||
/// Net rpc implementation.
|
||||
pub struct NetClient;
|
||||
pub struct NetClient {
|
||||
sync: Arc<EthSync>
|
||||
}
|
||||
|
||||
impl NetClient {
|
||||
/// Creates new NetClient.
|
||||
pub fn new() -> Self { NetClient }
|
||||
pub fn new(sync: Arc<EthSync>) -> Self {
|
||||
NetClient {
|
||||
sync: sync
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Net for NetClient {
|
||||
fn version(&self, _: Params) -> Result<Value, Error> {
|
||||
Ok(Value::U64(63))
|
||||
Ok(Value::U64(self.sync.status().protocol_version as u64))
|
||||
}
|
||||
|
||||
fn peer_count(&self, _params: Params) -> Result<Value, Error> {
|
||||
Ok(Value::U64(0))
|
||||
Ok(Value::U64(self.sync.status().num_peers as u64))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user