ethereum / ethereum/ddht

Dispatcher subscription API should allow filtering for only responses that were triggered by a request

Open
#67 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
19
Forks
15
PR merge metrics
No merged PRs in 30d

Description

## What was wrong?

Suppose we want to monitor for the PONG side of PING/PONG requests.

```python
async with dispatcher.subscribe(PingMessage) as subscription:
async for message in subscription:
... # do things with it
```

The subtle problem with this is that it will include *unsolicited* pong messages (such as a node sending a pong when no ping was sent).

## How can it be fixed?

The dispatcher subscription API should be updated to allow an extra filtering parameter, something like `only_responses = True`. In this case, the subscription should only be triggered *if* it occured due to a corresponding request (probably by checking for an active `request_id`). Care will need to be taken to ensure that this works reliably since `the request/response` API controls the allocation of request ids and it is possible for a request id to be garbage collected before all of the subscription messages have been dispatched.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.