Commit Graph

165 Commits

Author SHA1 Message Date
fabf2cefc4 feat: implement get_remote_address via delegation pattern 2025-03-24 08:02:21 -06:00
d7eab27564 refactored and moved all interfaces to abc.py (#504)
* refactored : host_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored : network_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored : notifee_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored : net_connection_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored: raw_connection_interface, secure_conn_interface and stream_muxer abc.py

* refactored: addrbook_interface

* refactored :peerdata_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :peermetadata_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :multiselect_client_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :multiselect_communicator_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :multiselect_muxer_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :interfaces

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :security_transport_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* refactored :listener_interface

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* moved all interfaces and typing files

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>

* fixed documentation and moved pubsub abc.py

Co-authored-by: Khwahish Patel <khwahish.p1@ahduni.edu.in>

* added exclude-members in custom_types docs

* added : newsfragment for moving all interfaces to libp2p.abc

---------

Co-authored-by: mystical-prog <jdgt.vd.0405@gmail.com>
Co-authored-by: Mystical <125946525+mystical-prog@users.noreply.github.com>
2025-02-21 16:01:45 -07:00
e7a9ee78a8 rename typing.py to custom_types.py for clarity 2025-02-02 07:18:52 -07:00
8787613e91 run lint with pyupgrade at py39-plus 2025-01-25 15:48:39 -07:00
d9b92635c1 drop async-service dep and copy relevant code into a local async_service
tool, updated for modern handling of ExceptionGroup
2024-05-27 12:14:36 -06:00
8dda7b933e turn mypy checks back on, fix some errors 2024-04-27 10:12:39 -06:00
94483714a3 run lint and fix errors, except mypy 2024-02-19 16:05:58 -07:00
fb53edbc04 Change async def write
To return `None` instead of `int. `Writer.write` *does* write all data
in all use case.
2020-02-08 10:24:37 +08:00
f1dbd52d67 Merge branch 'master' into feature/trio 2020-02-06 10:39:54 +08:00
ba0fb8a833 Fix: use pass over ...(Ellipse)
Use `...`(Ellipse) only in abstract methods.
2020-02-05 20:36:42 +08:00
12cb0d9ac4 Swarm: change notify_xxx back to async func 2020-02-04 22:56:13 +08:00
13930ae718 SwarmConn: perform close right away
In `_handle_new_streams`, when the underlying muxed conn is unavailable,
close `SwarmConn` itself right away, to reset all the streams.
Therefore, the stream processed by `_handle_muxed_stream` are conscious
of the fact that they are reset. It allows a more graceful clean up.
2020-02-04 22:51:21 +08:00
f884bfa39e SwarmConn: don't access Swarm.manager
Open a local nursery instead.
2020-02-04 21:57:11 +08:00
a7ba59bf9f Add a nursery in Swarm
To avoid using the one in `Service`
2020-02-04 20:45:58 +08:00
3a91f114ab Swarm: add default_stream_handler
Advantage:
- To avoid `None` checks
- If users forget to register a stream handler for `Swarm`,
with the default stream handler, opened streams aren't removed
until `Swarm` finishes.
2020-02-04 17:05:53 +08:00
3fc60cb312 SwarmConn: iterate streams.copy in _cleanup
To avoid `RuntimeError` if `streams` is changed.
2020-02-04 17:04:28 +08:00
d483982acb SwarmConn: don't catch exceptions in handler 2020-02-04 15:10:49 +08:00
e57d01f360 PR feedback
- Use f-string
- Fix wrongly indented comments
- Add dep `trio-typing`
2020-01-28 15:48:41 +08:00
42bc4d5d06 INetworkService implement ServiceAPI 2020-01-26 23:55:31 +08:00
ddfbf9ffc8 Use raise from to reserve stacktrace 2020-01-26 23:54:29 +08:00
5b4b65faa8 Change default value of read()
From `n = -1` to `n = None`, to comply with trio API
2020-01-26 23:03:38 +08:00
4c3510f738 Merge branch 'master' into f-string_clean
# Conflicts:
#	libp2p/network/connection/raw_connection.py
2020-01-20 11:25:37 +01:00
f0c4254bbd Use Service instead of ServiceAPI
To fix error with async-service==0.1.0a5
2020-01-18 00:31:39 +08:00
eef241e70e Make Mplex and SwarmConn not Service
After second thoughts, they seem not a good candidate of `Service`.
The shutdown logic becomes simpler by making them not `Service`.
2020-01-07 21:50:03 +08:00
45eeb4fba3 Change notify_xxx to sync functions
Since we already have `Swarm.run_task`, we can just change notify
functions to sync.
2020-01-07 16:45:06 +08:00
3b0386d861 Raise RawConnError 2019-12-24 22:27:16 +08:00
c62f1f374f Check if transport is closing before write/close 2019-12-24 22:23:38 +08:00
a390d21385 Remove RawConnError from exception handling 2019-12-24 21:57:13 +08:00
3372c32432 Fix examples and modify new_node
- Fix examples `chat.py` and `echo.py`
    - Use trio directly, instead of `trio-asyncio`
    - Remove redundant code
- Change entry API `new_node` to `new_host_trio`
2019-12-24 18:03:18 +08:00
8f52315816 Fix close an already reset connection 2019-12-24 16:19:49 +08:00
ce5663705f Merge branch 'master' into feature/porting-to-trio 2019-12-24 02:19:43 +08:00
96f6b80e51 Merge remote-tracking branch 'origin/master' into f-string_clean
# Conflicts:
#	libp2p/network/swarm.py
2019-12-23 09:14:15 +01:00
b1248ff315 enforced f-strings everywhere, %s on logging
extended _multiaddr_from_socket to support UDP and IPv6 automatically
changed TCPListener to use _ip4_or_6_from_multiaddr to get host, and not ip4 only

enforced `from error` everywhere with raises
added call braces to exceptions
2019-12-19 17:31:18 +01:00
6cf1b98a88 mark explicit modulo formatting (to get started with PR draft) 2019-12-19 00:37:09 +01:00
f54bc9d1af Make linter happy 2019-12-18 19:05:22 +01:00
81fe4049cf Apply PR review feedback
> add `if not addr` clause back
> use f-strings for exceptions instead of %s
2019-12-18 18:47:03 +01:00
4e4d91b2e2 Apply PR review suggestion (change "muxed" to "network" in docstrings)
Co-Authored-By: Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>
2019-12-18 10:54:52 +01:00
6b75901243 apply PR feedback (remote len == 0 block, remove redundant fixme comment + docstring line)
change wording of final SwarmException to include possible case of no addresses in returned address set

add `from error` in except clause
2019-12-17 20:20:09 +01:00
3cbe24caab fixes #384
also adds MultiError to libp2p/exceptions.py

and an additional fixme I have noticed
2019-12-17 12:00:11 +01:00
fb0519129d Refine Mplex.close and SwarmConn.close
Ensure `close` cleans up things and cancel the service finally.
2019-12-17 15:50:55 +08:00
3b9d7c7acd Apply PR feedback 2019-12-10 17:20:41 -08:00
1929f307fb Fix all modules except for security 2019-12-06 17:06:37 +08:00
63fd531ed0 Fixes to add python 3.6 compatibility 2019-12-02 16:33:32 -08:00
79fcdf3a02 Update tests in test_tcp.py
Besides, run `make format`
2019-12-01 16:26:16 +08:00
1e600ea7e0 Fix Mplex and Swarm 2019-11-29 19:09:56 +08:00
d503950179 Fix all doc build warnings 2019-11-26 17:44:33 -08:00
ec43c25b45 Rewrite factories, made some of the test running 2019-11-26 19:24:30 +08:00
a397ccdc04 makes test_mplex_stream.py::test_mplex_stream_read_write work 2019-11-26 15:27:06 +08:00
41ff884eef rewrite tcp reader/writer interface 2019-11-26 15:27:05 +08:00
501eef59de Apply PR feedback:
Only use pop method if graceful failure handling is desired
2019-11-21 14:48:03 +08:00