Commit Graph

437 Commits

Author SHA1 Message Date
c04d0fe797 Add back the Swarm (#613) 2018-11-07 19:29:07 +01:00
61f280f3ef Fix grammar in core/nodes etc. (#608)
* Fix grammar

* Nothing we can *do* except ...

* Implementer

* Implementation
2018-11-07 17:01:33 +01:00
1b4dada4d0 Inject event by value in ProtocolsHandler (#605) 2018-11-05 16:53:04 +01:00
4405518045 Add a PeriodicPingHandler and a PingListenHandler (#574)
* Add ProtocolsHandler trait

* Reexport symbols

* Add a note about shutting down

* Add a PeriodicPingHandler and a PingListenHandler

* Fix core doctest

* Add tolerating not supported

* Fix concerns
2018-11-04 09:47:15 +01:00
631ceaea4b Fix stack overflow when printing a SubstreamRef (#599)
* Fix stack overflow when printing a SubstreamRef

* Fix concern

* More problems
2018-11-03 09:54:31 +01:00
0f3ef5ee0a eg. -> e.g.; ie. -> i.e. via repren (#592)
* eg. -> e.g.; ie. -> i.e. via repren

* se.g. -> seg.
2018-11-02 16:40:00 +01:00
437a8c0fde Tests for HandledNode (#546)
* Add unit tests for core::nodes::NodeStream

* Move DummyMuxer to core/tests

* Address grumbles

* Impl Debug for SubstreamRef<P>

* Add test for poll()

* Don't need to open a substream

* pretty printer test

* More tests for NodeStream poll()

* ListenerStream unit tests: transport() and listeners()

* Tests for nodes/listeners.rs

* Add a few tests to help illustrate the "drowning" behaviour of busy listeners

* Tests for HandledNode

* Address grumbles

* Remove non-project specific stuff

* Address grumbles

* Prefer freestanding function

* Untangle the code for old shutdown test from the new tests
Add HandlerState and use it in TestBuilder
Shorter test names

* WIP – tests pass

* Use a newtype to lighten up the function signatures a bit
Test NotReady case

* Cleanup Event enum
Track events as they reach the Handler
Describe complex test logic

* Assert on the event trace

* More tests for poll()

* Switch to using usize as the OutboundOpenInfo so we can assert on event contents
More tests for poll()

* whitespace

* Move Handler related code to dummy_handler

* Fixes broken test after upstream changes

* Clarify the behaviour of is_shutting_down

* Fix broken test

* Fix tests after recent changes on master

* no tabs

* whitespace

* rustfmt

* Add public HandledNode.handler() method that returns a ref to the NodeHandler
Don't use private members in tests

* Add HandledNode.handler_mut that returns a mutable ref to the NodeHandler

* Remove debugging stmts

* Fix parse error
2018-11-02 14:12:21 +01:00
9249e31218 Some minor fixes reported by clippy (#600) 2018-11-02 13:15:17 +01:00
c730b4b3c9 Add ProtocolsHandler trait (#573)
* Add ProtocolsHandler trait

* Reexport symbols

* Add a note about shutting down

* Add map_protocol

* Add a NodeHandlerWrapperBuilder

* Update core/src/nodes/protocols_handler.rs

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>

* Fix compilation
2018-11-01 11:06:32 +01:00
45cd7db6e9 Remove spaces before semicolons (#591) 2018-10-29 10:38:32 +01:00
585c90a33c Add protocol to report external address view. (#566)
Add protocol to report external address view.

Address part of #443.
2018-10-28 11:02:26 +01:00
490ae980c7 #399 remove tokio_current_thread tests (#577)
* remove tokio_current_thread tests

* Review changes:
Removed newline
Moved uds tokio test crate to top to avoid self and keep with convention of other test crates
Removed sleep from uds test and block until all futures are completed.
2018-10-25 11:26:37 +02:00
4a894851ab Remove even more unused files (#581)
* Remove even more unused files

* Remove dummy.rs as well
2018-10-23 12:07:06 +02:00
de26ba1d2d Fix the polling process in handled node (#582) 2018-10-20 13:12:05 +02:00
a77c1a6bf7 Fix panic in raw swarm (#571) 2018-10-18 09:42:20 +01:00
840663e181 Remove two unused files (#567) 2018-10-17 12:26:42 +01:00
5d1c54cc10 New core (#568)
* New core

* Fix lifetime requirements

* Remove identify transport

* Address &mut & ref ref mut

* Fix whitespaces
2018-10-17 10:17:40 +01:00
724d0f5d82 Remove the old API (#565)
* Remove the old API

* Fix integration test
2018-10-15 16:17:55 +01:00
2c98d06942 Change some nat_traversals to consider a prefix. (#550)
Change some `nat_traversal`s to consider a prefix.

Transports should consider only the relevant address prefix.
2018-10-15 16:29:32 +02:00
e179951c74 Add some documentation to listeners stream (#547)
* Add some documentation to listeners stream

* Fix concern
2018-10-15 11:12:40 +02:00
7d1a0238de Add shutdown functionality to NodeStream. (#560)
Add shutdown functionality to `NodeStream`.

Add `NodeStream::shutdown` to allow triggering the shutdown process,
and `NodeStream::poll_shutdown` as the internal way to drive any
potential shutdown to completion.
2018-10-15 10:42:11 +02:00
7016b86b3a Add StreamMuxer::flush. (#534)
Update the `StreamMuxer` trait.

- `read_substream`, `write_substream` and `flush_substream` now return `Poll` instead of `Result`.
- A new `Shutdown` enum allows for half-closing of substreams and is used in `shutdown_substream`.
- `close_inbound` and `close_outbound` have been merged into `shutdown` which takes a `Shutdown` parameter to allow closing only one direction.
- Add a new `flush_all` method  to allow flushing after a series of actions (e.g. multiple `shutdown_substream`).

W.r.t. flushing the general idea is that normal use drains buffers over time. Shutting down a substream does not imply flushing, so can be followed by `flush_substream` or (if multiple substreams are to be shut down) a single `flush_all`. Shutting down the muxer itself proceeds likewise, i.e. `shutdown` followed by `flush_all`.
2018-10-11 10:35:14 +02:00
0c7f313146 Tests for nodes/listeners.rs (#541)
* Add unit tests for core::nodes::NodeStream

* Move DummyMuxer to core/tests

* Address grumbles

* Impl Debug for SubstreamRef<P>

* Add test for poll()

* Don't need to open a substream

* pretty printer test

* More tests for NodeStream poll()

* ListenerStream unit tests: transport() and listeners()

* Tests for nodes/listeners.rs

* Add a few tests to help illustrate the "drowning" behaviour of busy listeners

* Address grumbles

* Remove non-project specific stuff

* Address grumbles

* Prefer freestanding function
2018-10-10 16:27:07 +02:00
d81f4e264f Add unit tests for core::nodes::NodeStream (#535)
* Add unit tests for core::nodes::NodeStream

* Move DummyMuxer to core/tests

* Address grumbles

* Impl Debug for SubstreamRef<P>

* Add test for poll()

* Don't need to open a substream

* pretty printer test

* More tests for NodeStream poll()

* Remove contentious test of Debug
2018-10-05 11:55:32 +02:00
7208bba92b Make it possible to accept/deny nodes in CollectionsStream (#512)
* Provide poll() as a regular method when we can't fail

* Add a CollectionReachEvent that allows accepting

* Add small TODO in handled_node

* Implement Debug on collection events

* Implement Debug for CollectionStream

* Implement Debug for structs in handled_node_tasks

* Attempt to fix compilation errors with stable Rust

* Prove the unwrap
2018-10-01 14:49:17 +02:00
4ff7d686a4 Fix polling in handled_node.rs (#531) 2018-10-01 14:24:01 +02:00
a9eefe1015 Remove notifying tasks (#528) 2018-10-01 11:18:00 +02:00
895557cb82 Fix handler not properly shut down, and write test for this (#514)
* Fix handler not properly shut down, and write test

* Remove to_notify from the test
2018-10-01 11:17:34 +02:00
ee9ff643a5 Split collection.rs in two (#507)
* Split collection.rs in two

* Fix forgot to interrupt inner task

* Another fix in collection.rs

* More qed
2018-09-21 17:31:52 +02:00
4fe92f81e8 Fix logic error in public key mismatch (#510) 2018-09-21 17:11:27 +02:00
a910797f22 Fix invalid state after peer id mismatch (#503) 2018-09-21 09:32:23 +02:00
84b089cacc Refactor multiaddr crate. (#498)
Refactor multiaddr crate.

- Remove `AddrComponent`. Instead `Protocol` directly contains its
associated data.

- Various smaller changes around conversions to Multiaddr from other
types, e.g. socket addresses.

- Expand tests to include property tests which test encoding/decoding
identity.
2018-09-20 19:51:00 +02:00
1969bde4fe Rework the Ping protocol (#497)
* Rework the Ping upgrade

* Fix concerns
2018-09-20 16:55:57 +02:00
f2a5eee5e8 Add a NodeHandler trait (#495)
* Add a NodeHandler trait

* Fix compilation

* Some fixes
2018-09-19 16:33:29 +02:00
8cf17f49e1 Add a basic test to listeners (#489) 2018-09-18 15:56:29 +02:00
783522f54c Prove the panics (#491) 2018-09-17 17:15:27 +02:00
0c43c76965 Implement close() from Sink (#492) 2018-09-17 15:01:37 +02:00
3e53a9dcc7 Fix additional addresses not tried (#483)
* Fix additional addresses not tried

* More fixes

* Produce a dialing error if unsupported multiaddr
2018-09-17 10:30:10 +02:00
2a7a48b496 Fix old task not interrupted after replacing (#482) 2018-09-14 20:40:28 +02:00
063ab178a9 Add an alternative to the swarm (#472)
* Rewrite the swarm

* Small improvement to Debug of ListenersStream

* Fix Swarm::Replaced never being produced

* Fix logic problem when reaching a node in swarm

* Small comment in swarm

* Add closed_multiaddr to Replaced event

* Add address to NodeClosed and NodeError

* Fix concerns

* Remove StreamMuxer::boxed
2018-09-14 13:18:10 +02:00
fd4b7488be Add some comments about the notification behaviour of muxers (#453) 2018-09-11 11:17:44 +02:00
381c071cbc Add BoxedMuxed transport (#459)
* Add BoxedMuxed transport

* Extend to both muxed and non-muxed versions

* Style

* Implement Debug for boxed transports
2018-09-06 16:59:47 +02:00
5c35047ee3 Change stream ID handling to consider flags. (#436)
Replaces the former odd/even distinction of IDs. However we still increment stream IDs by 2
for backwards compatibility.
2018-09-06 13:59:14 +02:00
ea1f172397 Implement Send everywhere (#458) 2018-09-06 09:54:35 +02:00
bca1083d9c Make the Futures in map_err Send-friendly (#418)
* Make the Futures in map_err Send-friendly

* Address concern
2018-09-05 09:09:32 +02:00
75ceba7809 The SwarmFuture is now a Stream (#442)
* The SwarmFuture is now a Stream

* Return the produced future in the message

* Remove IncomingConnection event

* Pass error when failing to dial

* Fix loop break mistake

* Fix concern

* Rename SwarmFuture to SwarmEvents

* Increase type length limit

* Remove todo
2018-09-04 14:53:27 +02:00
ee9be6f0c9 add must_use for Future (#450) 2018-09-04 12:30:57 +02:00
f787c80a42 Merge the changes from polkadot-2 into master (#446) 2018-09-03 16:46:15 +02:00
0e1483f02e Rework the StreamMuxer trait (#437)
* Stronger typing for the swarm handler future
* The swarm future is now a swarm stream of events
* Rewrite StreamMuxer in core
* Update libp2p_mplex for the new stream muxer
* Update yamux for new stream muxer
2018-08-31 10:31:34 +02:00
c02dea8128 Introduce several concrete future types. (#433)
* multisteam-select: introduce `DialerFuture`.

* multistream-select: add more concrete futures.

* multistream-select: add ListenerFuture.

* multistream-select: add ListenerSelectFuture

* Formatting.

* Add DialerSelectFuture type alias.

* Add UpgradeApplyFuture and NegotiationFuture.

* In iterator wrappers also pass-through size_hint.

* Minor refactoring.

* Address review comments.

* Add some comments.

* Hide state enums in wrapping structs.
2018-08-30 23:25:16 +02:00