12 Commits

Author SHA1 Message Date
Toralf Wittner
da05a10790
Shut down yamux and fix mplex shutdown. (#559)
mplex gets a new flag `is_shutdown` to keep track of when `shutdown` has
been called. We need to make certain that after the shutdown no more
`Sink::poll_complete` or `Sink::start_send` calls are being made which
may result in a panic.
2018-10-11 15:43:34 +02:00
Toralf Wittner
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
Pierre Krieger
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
Toralf Wittner
cfdfca1a06
Similar to #469, consider endpoint while retaining. (#470) 2018-09-10 14:03:38 +02:00
Toralf Wittner
ec6ec92a79
mplex: fix destroy_substream (#469)
Retain all incoming buffer elements with different substream ID or equal
Endpoint. The latter was previously not considered which could result in
the removal of data for another substream with same ID but opposite
Endpoint.
2018-09-10 10:21:19 +02:00
Pierre Krieger
bccd710fb4
Limit upload frame sizes to 1024 in mplex (#462) 2018-09-06 15:43:49 +02:00
Toralf Wittner
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
Pierre Krieger
ba4bd79fd9
Fix mplex notifications system (#455)
* Fix mplex notifications system

* Some fixes
2018-09-05 01:53:39 +02:00
Toralf Wittner
a6c82e6ca1
Use Bytes instead of BytesMut in mplex. (#456) 2018-09-04 16:12:58 +02:00
Pierre Krieger
5f0347a8b7
Cap the allocated buffer capacity in mplx (#449) 2018-09-03 18:33:51 +02:00
Pierre Krieger
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
Benjamin Kampmann
2ea49718f3
Clean up directory structure (#426)
* Remove unused circular-buffer crate
* Move transports into subdirectory
* Move misc into subdirectory
* Move stores into subdirectory
* Move multiplexers
* Move protocols
* Move libp2p top layer
* Fix Test: skip doctest if secio isn't enabled
2018-08-29 11:24:44 +02:00