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

Remove obsolete hack #1382

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions p2p/peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,18 +780,13 @@ def __init__(self,
self.event_bus = event_bus

async def handle_peer_count_requests(self) -> None:
async def f() -> None:
# FIXME: There must be a way to cancel event_bus.stream() when our token is triggered,
# but for the time being we just wrap everything in self.wait().
async for req in self.event_bus.stream(PeerCountRequest):
async for req in self.event_bus.stream(PeerCountRequest):
# We are listening for all `PeerCountRequest` events but we ensure to only send a
# `PeerCountResponse` to the callsite that made the request. We do that by
# retrieving a `BroadcastConfig` from the request via the
# `event.broadcast_config()` API.
self.event_bus.broadcast(PeerCountResponse(len(self)), req.broadcast_config())

await self.wait(f())

def __len__(self) -> int:
return len(self.connected_nodes)

Expand Down