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.
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.
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`.
* 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
Instead of having one struct with uninitialised fields
which are mutated, have explicit states and ensure that the types
show that there is no ambiguity which data is available or not.
Consequently, this removes quite a few `unwrap`/`expect` calls.
* 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
* Use the sha2 crate in the handshake
* Return a Digest in algo_support instead of a ring ref
* Switch to ed25519-dalek for keys
* Make ring more or less optional
* Switch to ed25519_dalek for the verification
* Extract the key exchange to its own module
* Remove the ring RNG from the handshake
* Some warning fixes and forgot file
* Move key exchange to own module
* Remove usage of ring::digest
* Remove ring from handshake entirely
* Implement ECDH for WebCrypto
* Remove the libp2p-secio feature
* Fix ring being included
* Address some concerns
* Provde some panics in WebCrypto
* Prove the Hmac panic
* Prove more panics
* 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
* Add support for unsigned varints
* Depend on unsigned-varint 0.2 without default features
* Change hash code type from u8 to u64
* Fix hash codes and enum variants for BLAKE2 to fit the standard (see #524)
* Run cargo fmt on crate
* Expand hash_types test to include all variants
* Add support for BLAKE2b-512 and BLAKE2s-256
* Depend on blake2 crate 0.7 with no default features
* Update encode! macro for support for blake2 crate
* Update all tests to include BLAKE2b-512 and BLAKE2s-256
* Reduce hash code size from u64 to u16
* Fix typo in doc comment
* Bump tiny-keccak to version 1.4
* Remove unnecessary default-features = false in Cargo.toml
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.
* secio: keep ciphertext if start_send is not ready
Otherwise ciphertext may be thrown away and once sent, the cipher states
have diverged, resulting in nonsense messages on decryption side.
* Also attempt to send pending data `Sink::close`.
* Inline `send_pending`.
* 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
* Use `unsigned-varint` crate.
* Implement `Display` for `Protocol`.
Gives `ToString` for free.
* Use `Cow` in `AddrComponent`.
* Add `AddrComponent::acquire`.
* Document `AddrComponent::acquire`.
* Introduce NULL cipher and allow more configuration.
* Back to using the hash-code for handshake.
Using `Endpoint` would be incompatible with the existing protocol.
* Add comments.
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.