-
Notifications
You must be signed in to change notification settings - Fork 379
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
The transport layer should not know about events #2420
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,9 @@ | |
RaidenShuttingDown, | ||
UnknownAddress, | ||
) | ||
|
||
from raiden.message_handler import on_message | ||
from raiden.messages import Delivered, Message, Ping, Pong, decode, message_from_sendevent | ||
from raiden.messages import Delivered, Message, Ping, Pong, decode | ||
from raiden.network.transport.udp import healthcheck | ||
from raiden.network.transport.udp.udp_utils import ( | ||
event_first_of, | ||
|
@@ -207,7 +208,7 @@ def __init__(self, discovery, udpsocket, throttle_policy, config): | |
def start( | ||
self, | ||
raiden: RaidenService, | ||
queueids_to_queues: typing.Dict[QueueIdentifier, typing.List[Event]], | ||
queueids_to_queues: typing.Dict[QueueIdentifier, typing.List[Message]], | ||
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 should use QueueIdsToQueues here, and change the type there |
||
): | ||
if not self.event_stop.ready(): | ||
raise RuntimeError('UDPTransport started while running') | ||
|
@@ -221,15 +222,10 @@ def start( | |
self.server.set_handle(self._receive) | ||
|
||
for queue_identifier, queue in queueids_to_queues.items(): | ||
encoded_queue = list() | ||
|
||
for sendevent in queue: | ||
message = message_from_sendevent(sendevent, raiden.address) | ||
raiden.sign(message) | ||
encoded = message.encode() | ||
|
||
encoded_queue.append((encoded, sendevent.message_identifier)) | ||
|
||
encoded_queue = [ | ||
(message.encode(), message.message_identifier) | ||
for message in queue | ||
] | ||
self.init_queue_for(queue_identifier, encoded_queue) | ||
|
||
self.server.start() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You need to adapt all uses of
_queueids_to_queues
to iterate overMessage
s instead ofSendMessageEvent
s, or possibly just plainin
test:_receive_delivered
_send_with_retry
send_async
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.
I don't follow, what are you referring to?
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.
The methods I enumerated above use
_queueids_to_queues
as the values beingList[SendMessageEvent]
, specifically iterating over the events and comparing themessage_identifier
of the message with the attribute of the same name of the event. If now theQueueIdsToQueues
is an alias forDict[QueueIdentifier, List[Message]]
, you need to update the type alias and ensure these places where this mapping is used comply with this new signature. If theMessage
instance passed to transport is the same inside the various versions/instances of this map, or allMessage
instances implements correctly equality comparison, you may want to optimize these lookups by using something likemessage in self._queueids_to_queues[queue_identifier]
, instead of theany
iterator.