I'm trying to figure out how a node maintains its list of anchor peers. I know that they are important when a node restarts. However, when does a node add and remove other nodes to its anchor peer list? And does this list interact with the list of white and grey peers? Because in the function connections_maker, a node does some computations and depending on these it tries to connect to a peer of this anchor list.

1 Answer 1


Leaving aside exclusive peers, when a node starts for the very first time, it connects to the seed peer(s) to get an initial peer list. It then attempts to maintain at least 2 anchor peers (if it successfully handshakes with an attempted peer and doesn't already have enough anchor peers, it can be added to the anchor list).

If an anchor node goes away, it is removed from the peer list and another white peer is attempted to be added as a new anchor. The node also broadcasts its updated peer list.

All other peers are either in the gray or white peer lists. The gray list contains a list of peers that the node has not attempted to connect to and the white list contains a list of peers the node has successfully performed a handshake with.

Whenever a new peer list is broadcast (so from one of the connected peers), the white and gray peers received get merged into the receiving nodes peer list. The node then broadcasts this list with it's connected peers.

Essentially, each node needs to maintain some connected nodes, some nodes known to be online and some nodes not yet attempted to connect to. connections_maker is called periodically to keep these lists healthy.

Lastly, the nodes peer lists are persisted to ~/.bitmonero/p2pstate.bin. This is saved periodically and on shutdown. Upon startup, it is loaded to initialize the peer lists, which puts less reliance on the seed nodes (e.g. if you connect to enough peers from the saved peers, there is no need to use the seed nodes, they become fallbacks).

  • Thanks! How does a node exactly merge the lists? Do nodes only broadcast their white list? And in case they receive a peer list, do they merge this received list only with their gray list?
    – Jan Telov
    Apr 18, 2019 at 8:02
  • 1
    The senders white and gray peers are merged together and added to the receivers gray list. If the sender itself was not already in the receivers white list, or was in the gray list, it is added to the receivers white list.
    – jtgrassie
    Apr 18, 2019 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.