Increase number of requested block bodies in chain sync (#10247)
* Increase the number of block bodies requested during Sync. * Increase the number of block bodies requested during Sync. * Check if our peer is an older parity client with the bug of not handling large requests properly * Add a ClientVersion struct and a ClientCapabilites trait * Make ClientVersion its own module * Refactor and extend use of ClientVersion * Replace strings with ClientVersion in PeerInfo * Group further functionality in ClientCapabilities * Move parity client version data from tuple to its own struct. * Implement accessor methods for ParityClientData and remove them from ClientVersion. * Minor fixes * Make functions specific to parity return types specific to parity. * Test for shorter ID strings * Fix formatting and remove unneeded dependencies. * Roll back Cargo.lock * Commit last Cargo.lock * Convert from string to ClientVersion * * When checking if peer accepts service transactions just check if it's parity, remove version check. * Remove dependency on semver in ethcore-sync * Remove unnecessary String instantiation * Rename peer_info to peer_version * Update RPC test helpers * Simplify From<String> * Parse static version string only once * Update RPC tests to new ClientVersion struct * Document public members * More robust parsing of ID string * Minor changes. * Update version in which large block bodies requests appear. * Update ethcore/sync/src/block_sync.rs Co-Authored-By: elferdo <elferdo@gmail.com> * Update util/network/src/client_version.rs Co-Authored-By: elferdo <elferdo@gmail.com> * Update util/network/src/client_version.rs Co-Authored-By: elferdo <elferdo@gmail.com> * Update tests. * Minor fixes.
This commit is contained in:
@@ -42,6 +42,7 @@ use network::{NetworkConfiguration, NetworkIoMessage, ProtocolId, PeerId, Packet
|
||||
use network::{NonReservedPeerMode, NetworkContext as NetworkContextTrait};
|
||||
use network::{SessionInfo, Error, ErrorKind, DisconnectReason, NetworkProtocolHandler};
|
||||
use discovery::{Discovery, TableUpdates, NodeEntry, MAX_DATAGRAM_SIZE};
|
||||
use network::client_version::ClientVersion;
|
||||
use ip_utils::{map_external_address, select_public_address};
|
||||
use parity_path::restrict_permissions_owner;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
@@ -180,8 +181,8 @@ impl<'s> NetworkContextTrait for NetworkContext<'s> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn peer_client_version(&self, peer: PeerId) -> String {
|
||||
self.resolve_session(peer).map_or("unknown".to_owned(), |s| s.lock().info.client_version.clone())
|
||||
fn peer_client_version(&self, peer: PeerId) -> ClientVersion {
|
||||
self.resolve_session(peer).map_or(ClientVersion::from("unknown").to_owned(), |s| s.lock().info.client_version.clone())
|
||||
}
|
||||
|
||||
fn session_info(&self, peer: PeerId) -> Option<SessionInfo> {
|
||||
|
||||
@@ -29,6 +29,7 @@ use handshake::Handshake;
|
||||
use io::{IoContext, StreamToken};
|
||||
use network::{Error, ErrorKind, DisconnectReason, SessionInfo, ProtocolId, PeerCapabilityInfo};
|
||||
use network::SessionCapabilityInfo;
|
||||
use network::client_version::ClientVersion;
|
||||
use host::*;
|
||||
use node_table::NodeId;
|
||||
use snappy;
|
||||
@@ -112,7 +113,7 @@ impl Session {
|
||||
had_hello: false,
|
||||
info: SessionInfo {
|
||||
id: id.cloned(),
|
||||
client_version: String::new(),
|
||||
client_version: ClientVersion::from(""),
|
||||
protocol_version: 0,
|
||||
capabilities: Vec::new(),
|
||||
peer_capabilities: Vec::new(),
|
||||
@@ -419,7 +420,8 @@ impl Session {
|
||||
fn read_hello<Message>(&mut self, io: &IoContext<Message>, rlp: &Rlp, host: &HostInfo) -> Result<(), Error>
|
||||
where Message: Send + Sync + Clone {
|
||||
let protocol = rlp.val_at::<u32>(0)?;
|
||||
let client_version = rlp.val_at::<String>(1)?;
|
||||
let client_version_string = rlp.val_at::<String>(1)?;
|
||||
let client_version = ClientVersion::from(client_version_string);
|
||||
let peer_caps: Vec<PeerCapabilityInfo> = rlp.list_at(2)?;
|
||||
let id = rlp.val_at::<NodeId>(4)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user