Use network id for the web3_net_version return.
This commit is contained in:
parent
28122a1e89
commit
f231440480
@ -36,7 +36,7 @@ impl<S> NetClient<S> where S: SyncProvider {
|
|||||||
|
|
||||||
impl<S> Net for NetClient<S> where S: SyncProvider + 'static {
|
impl<S> Net for NetClient<S> where S: SyncProvider + 'static {
|
||||||
fn version(&self, _: Params) -> Result<Value, Error> {
|
fn version(&self, _: Params) -> Result<Value, Error> {
|
||||||
Ok(Value::String(format!("{}", take_weak!(self.sync).status().protocol_version).to_owned()))
|
Ok(Value::String(format!("{}", take_weak!(self.sync).status().network_id).to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn peer_count(&self, _params: Params) -> Result<Value, Error> {
|
fn peer_count(&self, _params: Params) -> Result<Value, Error> {
|
||||||
|
@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
//! Test implementation of SyncProvider.
|
//! Test implementation of SyncProvider.
|
||||||
|
|
||||||
|
use util::U256;
|
||||||
use ethsync::{SyncProvider, SyncStatus, SyncState};
|
use ethsync::{SyncProvider, SyncStatus, SyncState};
|
||||||
use std::sync::{RwLock};
|
use std::sync::{RwLock};
|
||||||
|
|
||||||
/// TestSyncProvider config.
|
/// TestSyncProvider config.
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Protocol version.
|
/// Protocol version.
|
||||||
pub protocol_version: u8,
|
pub network_id: U256,
|
||||||
/// Number of peers.
|
/// Number of peers.
|
||||||
pub num_peers: usize,
|
pub num_peers: usize,
|
||||||
}
|
}
|
||||||
@ -39,7 +40,8 @@ impl TestSyncProvider {
|
|||||||
TestSyncProvider {
|
TestSyncProvider {
|
||||||
status: RwLock::new(SyncStatus {
|
status: RwLock::new(SyncStatus {
|
||||||
state: SyncState::NotSynced,
|
state: SyncState::NotSynced,
|
||||||
protocol_version: config.protocol_version,
|
network_id: config.network_id,
|
||||||
|
protocol_version: 63,
|
||||||
start_block_number: 0,
|
start_block_number: 0,
|
||||||
last_imported_block_number: None,
|
last_imported_block_number: None,
|
||||||
highest_block_number: None,
|
highest_block_number: None,
|
||||||
|
@ -21,7 +21,7 @@ use v1::tests::helpers::{Config, TestSyncProvider};
|
|||||||
|
|
||||||
fn sync_provider() -> Arc<TestSyncProvider> {
|
fn sync_provider() -> Arc<TestSyncProvider> {
|
||||||
Arc::new(TestSyncProvider::new(Config {
|
Arc::new(TestSyncProvider::new(Config {
|
||||||
protocol_version: 65,
|
network_id: 3,
|
||||||
num_peers: 120,
|
num_peers: 120,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ fn rpc_net_version() {
|
|||||||
io.add_delegate(net);
|
io.add_delegate(net);
|
||||||
|
|
||||||
let request = r#"{"jsonrpc": "2.0", "method": "net_version", "params": [], "id": 1}"#;
|
let request = r#"{"jsonrpc": "2.0", "method": "net_version", "params": [], "id": 1}"#;
|
||||||
let response = r#"{"jsonrpc":"2.0","result":"65","id":1}"#;
|
let response = r#"{"jsonrpc":"2.0","result":"3","id":1}"#;
|
||||||
|
|
||||||
assert_eq!(io.handle_request(request), Some(response.to_owned()));
|
assert_eq!(io.handle_request(request), Some(response.to_owned()));
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,8 @@ pub struct SyncStatus {
|
|||||||
pub state: SyncState,
|
pub state: SyncState,
|
||||||
/// Syncing protocol version. That's the maximum protocol version we connect to.
|
/// Syncing protocol version. That's the maximum protocol version we connect to.
|
||||||
pub protocol_version: u8,
|
pub protocol_version: u8,
|
||||||
|
/// The underlying p2p network version.
|
||||||
|
pub network_id: U256,
|
||||||
/// BlockChain height for the moment the sync started.
|
/// BlockChain height for the moment the sync started.
|
||||||
pub start_block_number: BlockNumber,
|
pub start_block_number: BlockNumber,
|
||||||
/// Last fully downloaded and imported block number (if any).
|
/// Last fully downloaded and imported block number (if any).
|
||||||
@ -249,6 +251,7 @@ impl ChainSync {
|
|||||||
SyncStatus {
|
SyncStatus {
|
||||||
state: self.state.clone(),
|
state: self.state.clone(),
|
||||||
protocol_version: 63,
|
protocol_version: 63,
|
||||||
|
network_id: self.network_id,
|
||||||
start_block_number: self.starting_block,
|
start_block_number: self.starting_block,
|
||||||
last_imported_block_number: self.last_imported_block,
|
last_imported_block_number: self.last_imported_block,
|
||||||
highest_block_number: self.highest_block,
|
highest_block_number: self.highest_block,
|
||||||
|
Loading…
Reference in New Issue
Block a user