* parity-version: mark 2.1.0 track beta * ci: update branch version references * docker: release master to latest * Fix checkpointing when creating contract failed (#9514) * ci: fix json docs generation (#9515) * fix typo in version string (#9516) * Update patricia trie to 0.2.2 crates. Default dependencies on minor version only. * Putting back ethereum tests to the right commit * Enable all Constantinople hard fork changes in constantinople_test.json (#9505) * Enable all Constantinople hard fork changes in constantinople_test.json * Address grumbles * Remove EIP-210 activation * 8m -> 5m * Temporarily add back eip210 transition so we can get test passed * Add eip210_test and remove eip210 transition from const_test * In create memory calculation is the same for create2 because the additional parameter was popped before. (#9522) * deps: bump fs-swap and kvdb-rocksdb * Multithreaded snapshot creation (#9239) * Add Progress to Snapshot Secondary chunks creation * Use half of CPUs to multithread snapshot creation * Use env var to define number of threads * info to debug logs * Add Snapshot threads as CLI option * Randomize chunks per thread * Remove randomness, add debugging * Add warning * Add tracing * Use parity-common fix seek branch * Fix log * Fix tests * Fix tests * PR Grumbles * PR Grumble II * Update Cargo.lock * PR Grumbles * Default snapshot threads to half number of CPUs * Fix default snapshot threads // min 1 * correct before_script for nightly build versions (#9543) - fix gitlab array of strings syntax error - get proper commit id - avoid colon in stings * Remove initial token for WS. (#9545) * version: mark release critical * ci: fix rpc docs generation 2 (#9550) * Improve P2P discovery (#9526) * Add `target` to Rust traces * network-devp2p: Don't remove discovery peer in main sync * network-p2p: Refresh discovery more often * Update Peer discovery protocol * Run discovery more often when not enough nodes connected * Start the first discovery early * Update fast discovery rate * Fix tests * Fix `ping` tests * Fixing remote Node address ; adding PingPong round * Fix tests: update new +1 PingPong round * Increase slow Discovery rate Check in flight FindNode before pings * Add `deprecated` to deprecated_echo_hash * Refactor `discovery_round` branching * net_version caches network_id to avoid redundant aquire of sync read lock (#9544) * net_version caches network_id to avoid redundant aquire of sync read lock, #8746 * use lower_hex display formatting for net_peerCount rpc method * Increase Gas-floor-target and Gas Cap (#9564) + Gas-floor-target increased to 8M by default + Gas-cap increased to 10M by default * Revert to old parity-tokio-ipc. * Downgrade named pipes.
60 lines
1.7 KiB
Rust
60 lines
1.7 KiB
Rust
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity.
|
|
|
|
// Parity 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.
|
|
|
|
// Parity 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 Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! Net rpc implementation.
|
|
use std::sync::Arc;
|
|
use jsonrpc_core::Result;
|
|
use sync::SyncProvider;
|
|
use v1::traits::Net;
|
|
|
|
/// Net rpc implementation.
|
|
pub struct NetClient<S: ?Sized> {
|
|
sync: Arc<S>,
|
|
/// Cached `network_id`.
|
|
///
|
|
/// We cache it to avoid redundant aquire of sync read lock.
|
|
/// https://github.com/paritytech/parity-ethereum/issues/8746
|
|
network_id: u64,
|
|
}
|
|
|
|
impl<S: ?Sized> NetClient<S> where S: SyncProvider {
|
|
/// Creates new NetClient.
|
|
pub fn new(sync: &Arc<S>) -> Self {
|
|
NetClient {
|
|
sync: sync.clone(),
|
|
network_id: sync.status().network_id,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<S: ?Sized> Net for NetClient<S> where S: SyncProvider + 'static {
|
|
fn version(&self) -> Result<String> {
|
|
Ok(format!("{}", self.network_id))
|
|
}
|
|
|
|
fn peer_count(&self) -> Result<String> {
|
|
Ok(format!("{:#x}", self.sync.status().num_peers as u64))
|
|
}
|
|
|
|
fn is_listening(&self) -> Result<bool> {
|
|
// right now (11 march 2016), we are always listening for incoming connections
|
|
//
|
|
// (this may not be true now -- 26 september 2016)
|
|
Ok(true)
|
|
}
|
|
|
|
}
|