> ## Documentation Index
> Fetch the complete documentation index at: https://docs.towns.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node to Node communication

## How it works

Nodes communicate with each other using the `NodeToNode` service defined in the [protocol](https://github.com/towns-protocol/towns/blob/main/protocol/internode.proto).

The envelope is received through the `NodeToNode.NewEventReceived` RPC from the node that is processing the `StreamService.AddEvent` client RPC request.
The node verifies if the action is permitted, by validating the signature of the event.
The event is then added to the minipool of the stream and committed to local storage.
A success response is sent to the `NodeToNode.NewEventReceived` RPC.
A `NodeToNode.NewEventInPool` message, containing the event hash, is broadcast to the stream node, excluding the original `NodeToNode.NewEventReceived` RPC caller.

Once a majority of minipools contain the event, the event is sent to any client monitoring the given stream through a Sync RPC call.

* The number of minipools is calculated by counting the local minipool and the number of `NodeToNode.NewEventInPool` messages received.
