Skip to content

Onion Message Responder creates a circular reference #3178

Closed
@TheBlueMatt

Description

@TheBlueMatt

To deal with #2882 we created a Responder, which message handlers can respond() on, then passing the response object back to the OnionMessager. Sadly, this isn't actually really workable as it creates a circular reference - the OnionMessager is typed on the message handler, and passes the messages to it to be handled. But to be able to respond async, we also expect the message handler to hold a reference to the OnionMessenger (and presumably be typed on it). While the type issue itself isn't as big a deal because we can use AOnionMessenger to avoid the type-inexpressibility, we cannot construct the two objects with a circular reference.

For the async gossip verification, we solved this by letting the gossiper take an Optional verifier, then let the user call set_verifier on the gossiper. This would mean the OnionMessenger would need to start taking Optional handlers (rather than IgnoringMessageHandler for no handler).

The other option would be to use the message handler traits, adding a PendingOnionMessage variant for a response or adding a new method to fetch responses ala release_pending_messages. The first here would be my preference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions