-
Notifications
You must be signed in to change notification settings - Fork 174
Feat/fix mplex stream muxer issues #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 14 commits
7f2c635
ca9bed4
8fd2d65
2fde49e
9595851
f8f93cc
eb3653e
881e5cb
d888938
80b0f12
750991b
5d5e33c
92b39fe
ec4eb83
e0f5dcd
aff17fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ downloads/ | |
wheels/ | ||
MANIFEST | ||
pip-wheel-metadata | ||
.ruff_cache | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,6 +16,7 @@ | |||||
|
||||||
from libp2p.abc import ( | ||||||
IHost, | ||||||
IMultiselectMuxer, | ||||||
INetConn, | ||||||
INetStream, | ||||||
INetworkService, | ||||||
|
@@ -130,7 +131,7 @@ def get_peerstore(self) -> IPeerStore: | |||||
""" | ||||||
return self.peerstore | ||||||
|
||||||
def get_mux(self) -> Multiselect: | ||||||
def get_mux(self) -> IMultiselectMuxer: | ||||||
""" | ||||||
:return: mux instance of host | ||||||
""" | ||||||
|
@@ -276,6 +277,7 @@ async def close(self) -> None: | |||||
async def _swarm_stream_handler(self, net_stream: INetStream) -> None: | ||||||
# Perform protocol muxing to determine protocol to use | ||||||
try: | ||||||
# The protocol returned here can now be None | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
protocol, handler = await self.multiselect.negotiate( | ||||||
MultiselectCommunicator(net_stream), self.negotiate_timeout | ||||||
) | ||||||
|
@@ -286,6 +288,25 @@ async def _swarm_stream_handler(self, net_stream: INetStream) -> None: | |||||
) | ||||||
await net_stream.reset() | ||||||
return | ||||||
|
||||||
# --- NEW CODE: Handle case where protocol is None --- | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if protocol is None: | ||||||
peer_id = net_stream.muxed_conn.peer_id | ||||||
logger.debug( | ||||||
"No protocol selected by peer %s during negotiation. Resetting stream.", | ||||||
peer_id, | ||||||
) | ||||||
await net_stream.reset() | ||||||
# The BasicHost analysis suggested raising StreamFailure here. | ||||||
# However, the current structure of _swarm_stream_handler | ||||||
# just returns on failure, so let's maintain that pattern | ||||||
# for now, unless further analysis suggests a raise is better. | ||||||
# For strict adherence to the analysis, it might be: | ||||||
# raise StreamFailure(f"No protocol selected from peer {peer_id}") | ||||||
# But the 'return' is consistent with the `except` block's handling. | ||||||
return | ||||||
# --- END NEW CODE --- | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
net_stream.set_protocol(protocol) | ||||||
if handler is None: | ||||||
logger.debug( | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,6 @@ def add_handler( | |
""" | ||
self.handlers[protocol] = handler | ||
|
||
# FIXME: Make TProtocol Optional[TProtocol] to keep types consistent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've removed the |
||
async def negotiate( | ||
self, | ||
communicator: IMultiselectCommunicator, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you're here, please update the docstring to match the arguments (specifically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Will do. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should move along with the class definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pacrob Will handle that as I clock in tommorrow.