Abstract devp2p (#8048)

* Rename ethcore-network to ethcore-network-devp2p

* Fix typo

* Extract generic traits into util/network

* Simplify util/network

* Fix devp2p tests

* Remove old feature

* Fix RPC tests
This commit is contained in:
Pierre Krieger
2018-03-05 11:56:35 +01:00
committed by Rando
parent 47a02480c4
commit eeee90def5
25 changed files with 568 additions and 397 deletions

View File

@@ -47,7 +47,7 @@ pub trait IoContext {
}
impl<'a> IoContext for NetworkContext<'a> {
impl<T> IoContext for T where T: ?Sized + NetworkContext {
fn send(&self, peer: PeerId, packet_id: u8, packet_body: Vec<u8>) {
if let Err(e) = self.send(peer, packet_id, packet_body) {
debug!(target: "pip", "Error sending packet to peer {}: {}", peer, e);

View File

@@ -1089,23 +1089,23 @@ impl NetworkProtocolHandler for LightProtocol {
}
fn read(&self, io: &NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]) {
self.handle_packet(io, peer, packet_id, data);
self.handle_packet(&io, peer, packet_id, data);
}
fn connected(&self, io: &NetworkContext, peer: &PeerId) {
self.on_connect(peer, io);
self.on_connect(peer, &io);
}
fn disconnected(&self, io: &NetworkContext, peer: &PeerId) {
self.on_disconnect(*peer, io);
self.on_disconnect(*peer, &io);
}
fn timeout(&self, io: &NetworkContext, timer: TimerToken) {
match timer {
TIMEOUT => self.timeout_check(io),
TICK_TIMEOUT => self.tick_handlers(io),
PROPAGATE_TIMEOUT => self.propagate_transactions(io),
RECALCULATE_COSTS_TIMEOUT => self.begin_new_cost_period(io),
TIMEOUT => self.timeout_check(&io),
TICK_TIMEOUT => self.tick_handlers(&io),
PROPAGATE_TIMEOUT => self.propagate_transactions(&io),
RECALCULATE_COSTS_TIMEOUT => self.begin_new_cost_period(&io),
_ => warn!(target: "pip", "received timeout on unknown token {}", timer),
}
}