rlp serialization refactor (#4873)
* fixed naming of rlp modules * RlpStream cleanup * appending short rlp lists (0...55 bytes) is 25% faster * RlpStream does not use bytes module, nor trait Stream * removed unused code from rlp module * compiling ethcore-util with new rlp serialization * compiling parity with new rlp serialization * fixed compiling ethcore-light with new rlp serialization * fixed compiling ethsync with new rlp serialization * removed redundant comment, print * removed redundant double-space * replace usage of WriteBytesExt with ByteOrder
This commit is contained in:
@@ -213,7 +213,7 @@ impl Discovery {
|
||||
let nearest = Discovery::nearest_node_entries(&self.discovery_id, &self.node_buckets).into_iter();
|
||||
let nearest = nearest.filter(|x| !self.discovery_nodes.contains(&x.id)).take(ALPHA).collect::<Vec<_>>();
|
||||
for r in nearest {
|
||||
let rlp = encode(&(&[self.discovery_id.clone()][..]));
|
||||
let rlp = encode_list(&(&[self.discovery_id.clone()][..]));
|
||||
self.send_packet(PACKET_FIND_NODE, &r.endpoint.udp_address(), &rlp);
|
||||
self.discovery_nodes.insert(r.id.clone());
|
||||
tried_count += 1;
|
||||
|
||||
@@ -59,8 +59,8 @@ pub struct Session {
|
||||
ping_time_ns: u64,
|
||||
pong_time_ns: Option<u64>,
|
||||
state: State,
|
||||
// Protocol states -- accumulates pending packets until signaled as ready.
|
||||
protocol_states: HashMap<ProtocolId, ProtocolState>,
|
||||
// Protocol states -- accumulates pending packets until signaled as ready.
|
||||
protocol_states: HashMap<ProtocolId, ProtocolState>,
|
||||
}
|
||||
|
||||
enum State {
|
||||
@@ -198,7 +198,7 @@ impl Session {
|
||||
ping_time_ns: 0,
|
||||
pong_time_ns: None,
|
||||
expired: false,
|
||||
protocol_states: HashMap::new(),
|
||||
protocol_states: HashMap::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -374,16 +374,16 @@ impl Session {
|
||||
self.connection().token()
|
||||
}
|
||||
|
||||
/// Signal that a subprotocol has handled the connection successfully and
|
||||
/// Signal that a subprotocol has handled the connection successfully and
|
||||
/// get all pending packets in order received.
|
||||
pub fn mark_connected(&mut self, protocol: ProtocolId) -> Vec<(ProtocolId, u8, Vec<u8>)> {
|
||||
match self.protocol_states.insert(protocol, ProtocolState::Connected) {
|
||||
None => Vec::new(),
|
||||
None => Vec::new(),
|
||||
Some(ProtocolState::Connected) => {
|
||||
debug!(target: "network", "Protocol {:?} marked as connected more than once", protocol);
|
||||
Vec::new()
|
||||
}
|
||||
Some(ProtocolState::Pending(pending)) =>
|
||||
Some(ProtocolState::Pending(pending)) =>
|
||||
pending.into_iter().map(|(data, id)| (protocol, id, data)).collect(),
|
||||
}
|
||||
}
|
||||
@@ -463,7 +463,7 @@ impl Session {
|
||||
rlp.begin_list(5)
|
||||
.append(&host.protocol_version)
|
||||
.append(&host.client_version)
|
||||
.append(&host.capabilities)
|
||||
.append_list(&host.capabilities)
|
||||
.append(&host.local_endpoint.address.port())
|
||||
.append(host.id());
|
||||
self.send(io, rlp)
|
||||
@@ -515,7 +515,7 @@ impl Session {
|
||||
self.info.protocol_version = protocol;
|
||||
self.info.client_version = client_version;
|
||||
self.info.capabilities = caps;
|
||||
self.info.peer_capabilities = peer_caps;
|
||||
self.info.peer_capabilities = peer_caps;
|
||||
if self.info.capabilities.is_empty() {
|
||||
trace!(target: "network", "No common capabilities with peer.");
|
||||
return Err(From::from(self.disconnect(io, DisconnectReason::UselessPeer)));
|
||||
|
||||
Reference in New Issue
Block a user