> For the complete documentation index, see [llms.txt](https://docs.hypertensor.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hypertensor.org/copy-of-subnet-template/examples/r.md).

# R

```python
        async def handle_vote(from_peer_id: ID, message: rpc_pb2.Message) -> None:
            payload = message.data.decode("utf-8")
            ...

        def validate_vote(from_peer_id: ID, message: rpc_pb2.Message) -> bool:
            return bool(message.data)

        termination_event = trio.Event()
        receiver = GossipReceiverTemplate(
            pubsub=pubsub,
            termination_event=termination_event,
            topics_config=[
                GossipTopicConfig(
                    topic="votes",
                    topic_handler=handle_vote,
                    topic_validator=validate_vote,
                ),
                GossipTopicConfig(
                    topic="peer_state",
                    topic_handler=handle_peer_state,
                    topic_validator=None,
                ),
            ],
        )

        async with trio.open_nursery() as nursery:
            nursery.start_soon(receiver.run)
            ...
            termination_event.set()

```
