Commit Graph

128 Commits

Author SHA1 Message Date
393b51a744 isort 2019-09-19 15:53:40 +08:00
5653b3f604 Add "closed" and "shutting_down" events 2019-09-19 15:53:39 +08:00
7cf0495f37 Remove print 2019-09-19 15:38:38 +08:00
0bd213bbb7 Refactor mplex and start to add close detection 2019-09-19 13:56:05 +08:00
559f419b4e Fix stream registration in accept_stream 2019-09-17 15:42:18 +08:00
76af835af8 Handle MultiselectError in stream_muxer.accept_stream 2019-09-15 17:35:01 +08:00
879f193aa1 Handle errors from
- `read_delim`
    - `read_varint_prefixed_bytes`
    - `decode_uvarint_from_stream`
2019-09-15 16:58:08 +08:00
31fb4e0b69 Rewrite _wait_for_data, to handle task precisely
Make the futures first, and then we can compare them with the return
value from `asyncio.wait`.
2019-09-10 23:38:45 +08:00
df87f5adb9 Add tests against the daemon for close/reset 2019-09-10 18:01:16 +08:00
e5eb01d22b Fix stream read 2019-09-10 18:01:16 +08:00
df312f3e57 Fix linting 2019-09-10 18:01:15 +08:00
be2c0f122a Fix close behavior 2019-09-10 18:01:14 +08:00
6c1f77dc1a Fix: Change the event.close to event.set
And add missing parts.
2019-09-06 21:35:15 +08:00
649a230776 Fix MplexStream.read 2019-09-06 17:26:40 +08:00
95926b7376 Temp for mplex_stream 2019-09-06 01:08:42 +08:00
207fa75d8f Add reset and close 2019-09-05 23:44:22 +08:00
10415cb956 Use ReadWriteCloser for conns and streams 2019-09-05 23:24:17 +08:00
eac159c527 Restructure mplex and mplex_stream 2019-09-05 22:29:33 +08:00
96230758e4 Add events in MplexStream
And modify a little bit of `close` and `reset`
2019-09-05 18:18:39 +08:00
c61a06706a Refactor interop tests and factories
- Add `close` and `disconnect` in `Host`
- Add `close` and `close_peer` in `Network`
- Change `IListener.close` to async, to await for server's closing
- Add factories for security transports, and modify `HostFactory`
2019-08-29 21:38:06 +08:00
34a4d7b0ed Add the missing StreamID class 2019-08-28 21:45:18 +08:00
d35b8ffc64 Conform stream_id to go-mplex 2019-08-28 21:43:34 +08:00
a193ae81fd Fix typo w/ header tag under different reset scenarios 2019-08-26 11:39:30 -07:00
b6c8ab0dc9 Fix #259: Use the unsigned LEB128 impl from py-wasm
Reference: https://github.com/ethereum/py-wasm/blob/master/wasm/parsers/leb128.py
2019-08-26 20:41:10 +08:00
d59870ebbf Fix MplexStream error
When receiving a `NewStream`, the message of that packet is the
name of the stream, which should be handled, rather than letting it go
into the message queue.
2019-08-26 20:39:08 +08:00
5e68aff1d1 Fix conn attribute and docstring in mplex 2019-08-25 14:42:44 +08:00
5b32bfdd3f Add call to wait_closed method of asyncio.StreamWriter 2019-08-24 22:06:24 +02:00
9c5fb4fa5a Encapsulate concept of a "stream id" to a "muxed" connection 2019-08-24 21:50:07 +02:00
e29c1507bf remove unused fields 2019-08-24 21:50:06 +02:00
ef476e555b Use RawConnection.read
Instead of accessing its reader and writer directly.

TODO: considering add `ReaderWriterCloser` interface and let connection
and stream inherit from it.
2019-08-22 22:53:48 +08:00
0b466ddc86 Add lock to RawConnection
To avoid `self.writer.drain()` is called in parallel.
Reference: https://bugs.python.org/issue29930
2019-08-22 22:53:47 +08:00
22b1a5395d A working plaintext 2.0 without validation 2019-08-22 22:53:46 +08:00
a0923d202a Move varint and delim read/write to toplevel
To `libp2p.utils`.
2019-08-22 22:53:46 +08:00
7bc363f2fa Remove initiator in Mplex
Besides, fix the wrong passed `multi_addr` to `mplex_stream`.
2019-08-22 22:53:45 +08:00
550c23f9f9 PR feedback
- Use the order in `MuxerMultistream` as the precedence in multiselect
2019-08-21 11:43:25 +08:00
8596f7390f PR feedback: set protocol_id to constants 2019-08-21 11:43:24 +08:00
d7d8440b2c PR feedback: nitpicks 2019-08-21 11:43:24 +08:00
4358a4bc89 Negotiate multiselect version for Muxer
`MuxerMultistream` is introduced to negotiate `Multiselect` version
before negotiating Multiplexer's version. This is required by
multistream 1.x
2019-08-21 11:43:24 +08:00
86d4ce1da8 Add delim_encode and delim_read
- Add `StreamCommunicator` and `RawConnectionCommunicator`, read/write
messages with delim codec, with `IMuxedStream` and `IRawConnection`
respectively.
- Use it in `Multiselect` and `MultiselectClient`.
2019-08-18 19:51:04 +08:00
c5f32bf431 PR feedback for MplexStream.read 2019-08-16 11:03:16 +08:00
8699568d43 Update libp2p/stream_muxer/mplex/mplex_stream.py
Co-Authored-By: Alex Stokes <r.alex.stokes@gmail.com>
2019-08-16 11:03:16 +08:00
b27cd0f24f Use bytearray over bytes
To avoid copies.
2019-08-16 11:03:16 +08:00
92320523d5 Add the missing exceptions.py 2019-08-16 11:03:16 +08:00
e37b8bcf19 mypy: Add read_buffer_nonblocking in Mplex 2019-08-16 11:03:16 +08:00
f281e3e1db flake8 2019-08-16 11:03:16 +08:00
9f8276fa84 Support read(n=-1)
Now, `n=-1` indicates that we want to read until EOF. However, now we
only read until we have no new message.
2019-08-16 11:03:16 +08:00
9cb6ec1c48 Modify the behavior of MplexStream.read 2019-08-16 11:03:16 +08:00
2485a00e24 Modify NetStream to read n bytes 2019-08-16 11:03:16 +08:00
82bae341a7 Run isort over files that were missing it 2019-08-15 16:33:35 -07:00
0ebc8ffb21 Wire some missing properties up 2019-08-15 16:33:34 -07:00