-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
(custom_proto::upgrade::RegisteredProtocols::find_protocol
is never used)
self.banned_peers.shrink_to_fit(); | ||
|
||
if !self.events.is_empty() { | ||
return Async::Ready(self.events.remove(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should self.events
be a VecDeque
to allow a more efficient pop
? Removing the head of a vector will always shift the remaining elements. Now I guess there will not be too many of those, but still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it's a SmallVec
, and since the elements are quite small I think it shouldn't be very expensive to remove the first element.
I think we should eventually remove this events system, but that requires some big modifications of the NetworkBehaviour
trait.
Co-Authored-By: tomaka <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good, just some nitpicks.
core/network-libp2p/src/behaviour.rs
Outdated
@@ -0,0 +1,262 @@ | |||
// Copyright 2018 Parity Technologies (UK) Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/network-libp2p/src/behaviour.rs
Outdated
|
||
impl<TSubstream> Behaviour<TSubstream> { | ||
/// Builds a new `Behaviour`. | ||
// TODO: redundancy between config and local_peer_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a github issue and put a link into the comment.
@@ -0,0 +1,471 @@ | |||
// Copyright 2018 Parity Technologies (UK) Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
} | ||
|
||
/// Try to add a reserved peer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why try
? The function does seem to try anything.
self.next_connect_to_nodes = Delay::new(Instant::now()); | ||
} | ||
|
||
/// Try to remove a reserved peer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
// Check whether peer is banned. | ||
if !is_reserved { | ||
if let Some((_, expire)) = self.banned_peers.iter().find(|(p, _)| p == &peer_id) { | ||
if *expire < Instant::now() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be *expire > Instant::now()
. Because when expire < Instant::now()
the ban is over?
@@ -0,0 +1,327 @@ | |||
// Copyright 2018 Parity Technologies (UK) Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,22 @@ | |||
// Copyright 2018 Parity Technologies (UK) Ltd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
core/network-libp2p/src/transport.rs
Outdated
.map(|(id, muxer), _| (id, StreamMuxerBox::new(muxer))); | ||
let peer_id2 = peer_id.clone(); | ||
let upgrade = core::upgrade::SelectUpgrade::new(yamux::Config::default(), mplex_config) | ||
// TODO: use a single `.map` instead of two maps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create and link a github issue.
* Update to latest libp2p * Fix indentations * Add basic test * Apply suggestions from code review Co-Authored-By: tomaka <[email protected]> * Remove Mutex from topology * Remove unused method * Fix concerns
…raud-proof-window-is-closed Finalize domains when the fraud proof period is over
Another networking rewrite.
Switches to libp2p 0.2 and moves a lot of code from Substrate to libp2p.
This fixes quite a lot of issues: