# Peer Discovery & Connection

Peers must have a way to connect to multiple peers. How peers connect to join the subnet is the only required understanding because once peers have joined, they will automatically discover one another because of the distributed hash table (DHT) as peers come and go.

## Connecting

Peers (or nodes) **connect to the AI network through bootnodes**. Bootnodes are peers whose only use case is to be a permanent peer for other peers to connect to the network.

All peers, including bootnode peers, run a proof-of-stake mechanism. This means that only subnet stakeholder participants can join the subnet. Further, all communication from then on also serves as proof of stake.

## Peer Discovery

{% hint style="info" %}
All peer discovery logic is handled by the [ServerBase](/copy-of-subnet-template/server.md). This is what the subnet's application logic is built on top of. Therefore, peer discovery is handled by the template itself.
{% endhint %}

Peers discover one another using a DHT (distributed hash table), which is a distributed system that provides a lookup service similar to a hash table. In short, it uses math and logic to trustlessly connect peers around the world, rather than relying on a central database, API, or trusted node.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hypertensor.org/copy-of-subnet-template/peer-discovery-and-connection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
