Skip to content
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 1 commit into from Sep 11, 2018

Conversation

hackaugusto
Copy link
Contributor

This changes the transport class to receive a list of message instead of
a list of events, which removes the necessity of encoding the event from
the transport and moves it to the raiden service.

fixes #2419

[ci integration]

@LefterisJP
Copy link
Contributor

rebasing this

This changes the transport class to receive a list of message instead of
a list of events, which removes the necessity of encoding the event from
the transport and moves it to the raiden service.

fixes raiden-network#2419

[ci integration]
@LefterisJP
Copy link
Contributor

Rebased on master and fixed conflicts.

Copy link
Contributor

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we should not be decoding the events in the transport layer but at one layer above it

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.006%) to 77.099% when pulling 3031a70 on hackaugusto:issue_2419 into 4619e80 on raiden-network:master.

@@ -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]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use QueueIdsToQueues here, and change the type there

@hackaugusto hackaugusto deleted the issue_2419 branch September 12, 2018 15:52
for event in events:
message = _event_to_message(event, node_address)
self._raiden_service.sign(message)
def _send_queued_messages(self, queueids_to_queues):
Copy link
Contributor

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 over Messages instead of SendMessageEvents, or possibly just plain in test:

  • _receive_delivered
  • _send_with_retry
  • send_async

Copy link
Contributor Author

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?

Copy link
Contributor

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 being List[SendMessageEvent], specifically iterating over the events and comparing the message_identifier of the message with the attribute of the same name of the event. If now the QueueIdsToQueues is an alias for Dict[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 the Message instance passed to transport is the same inside the various versions/instances of this map, or all Message instances implements correctly equality comparison, you may want to optimize these lookups by using something like message in self._queueids_to_queues[queue_identifier], instead of the any iterator.

hackaugusto pushed a commit that referenced this pull request Sep 13, 2018
Both transports currently basically do `send_async` on each message on
these queues anyway. This was done once to allow batch send, but it was
never implemented and matrix doesn't even support batch send messages,
so it was useless and cluttered the interface (send_async receives a
queue of events and a Message, and start received a queue of messages
since #2420).
The transports need to be aware of the events queues anyway, to
eventually stop retrying the message once it's cleaned (TODO for UDP),
so we can't avoid knowing about the events, but now the serialization
always occurs either in RaidenEventHandler or in RaidenService when
starting the transports, so consistent usage of
`messages.message_from_sendevent`
Followup of #2420 and replaces #2458
[ci integration]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node crashes when restarted
4 participants