New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New core #568
New core #568
Conversation
One big issue is that this breaks floodsub, as it is no longer capable of knowing which address we're talking to. |
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.
Great simplification!
Some files have trailing whitespace.
core/src/either.rs
Outdated
Ok(Async::Ready((EitherOutput::Second(item), future::Either::B(addr)))) | ||
} | ||
&mut EitherFuture::First(ref mut a) => a.poll().map(|v| v.map(EitherOutput::First)), | ||
&mut EitherFuture::Second(ref mut a) => a.poll().map(|v| v.map(EitherOutput::Second)), |
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.
Maybe we can remove ref mut
and &mut
now that rustc (>= 1.26) can handle this in match expressions?
type Listener: Stream<Item = Self::ListenerUpgrade, Error = IoError>; | ||
|
||
/// Future that produces the multiaddress of the remote. | ||
type MultiaddrFuture: Future<Item = Multiaddr, Error = IoError>; |
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.
👍
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.
What's the rationale for removing MultiaddrFuture
, considering that doing so breaks floodsub?
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.
Nevermind, I found #487.
} | ||
|
||
// TODO: remove unneeded bounds | ||
struct IdRetreiver<TMuxer> |
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.
Was id_transport.rs
supposed to be part of this PR? Regardless you probably meant IdRetriever
here.
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.
I'll submit it separately.
// TODO: right now it is possible for a node handler to be built, then shut down right after if we | ||
// realize we dialed the wrong peer for example ; this could be surprising and should either | ||
// be documented or changed (favouring the "documented" right now) | ||
pub trait NodeHandler<TSubstream> { | ||
pub trait NodeHandler { |
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 not keeping NodeHandler
generic over the substream type?
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.
If TSubstream
is generic, that means you can implement the NodeHandler
trait multiple times on the same struct with different types for TSubstream
.
However the implementation of NodeHandler
may need to store fields that depend on TSubstream
and therefore it doesn't make sense to allow multiple trait implementations.
That's the theoretical explanation, in practice I've encountered several inference issues with TSubstream
being generic.
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.
I think there is still trailing whitespace in several files. Maybe it could be removed before merging.
I don't see what the problem is with trailing whitespaces. Also this PR doesn't seem to add trailing whitespaces, so it can be done separately if necessary. |
It gets in the way by showing up in commit diffs and by potentially disturbing editing (e.g. when jumping to the end of a line). In general it requires extra work to cope with it, diff tools which need to ignore whitespace changes, extra editor commands to jump to the last non-whitespace character of a line, etc. On the other hand, what do we gain by adding trailing whitespace? Nothing.
|
Ah you meant whitespaces after the last character of a line. Fixed. |
…e-handled_node * upstream/master: New core (libp2p#568)
…e-handled_node_tasks * dp/chore/test-core-handled_node: Fix tests after recent changes on master New core (libp2p#568)
That's even more problematic when I'm extending floodsub with gossipsub in #521, and they both need to be in the same file. |
Now I'll need to go back to making floodsub compatible before I can continue working on gossipsub. |
Do you have any suggestions on how that may be done? |
That's unfortunately a hard question ; I'm currently waiting for a review on #573 then will probably update floodsub in a short time frame. |
…ref-debug-impl * upstream/master: Use paritytech/rust-secp256k1 (libp2p#598) Use websocket 0.21.0 (libp2p#597) Reexport multihash from the facade (libp2p#587) Add substrate to the list of projects using libp2p (libp2p#595) Remove spaces before semicolons (libp2p#591) Add protocol to report external address view. (libp2p#566) Add a TransportExt trait (libp2p#533) libp2p#399 remove tokio_current_thread tests (libp2p#577) Remove even more unused files (libp2p#581) Fix the polling process in handled node (libp2p#582) Fix panicking when Kad responder is destroyed (libp2p#575) Remove other unused files (libp2p#570) Fix panic in raw swarm (libp2p#571) Remove two unused files (libp2p#567) New core (libp2p#568) Remove the old API (libp2p#565) Change some `nat_traversal`s to consider a prefix. (libp2p#550) Add some documentation to listeners stream (libp2p#547) Add shutdown functionality to `NodeStream`. (libp2p#560)
* Fix panics? * Update protocols/gossipsub/src/behaviour.rs Co-authored-by: João Oliveira <hello@jxs.pt> --------- Co-authored-by: João Oliveira <hello@jxs.pt>
MultiaddrFuture
system from both theTransport
andConnectionUpgrade
traits.MuxedTransport
trait.Swarm
toRawSwarm
. The nameSwarm
should be for something higher level.poll()
methods that can't fail and can't end now return directlyAsync<Item>
instead ofPoll<Option<Item>, Error>
.HandledNodesTasks
andCollectionStream
now return back the handler if they failed to reach a node. This makes it possible for theRawSwarm
to reuse the same (yet unused) handler for multiple attempts.HandlerFactory
trait. When you use theRawSwarm
you must now manually pass a handler when you dial and on incoming connection.peer(peer_id).or_connect(handler)
and end up havinghandler
handle a different peer ID, which is confusing and a possible source of bugs.loop
in the TCP transport.