P2P Network of Miners
P2Poolv2 is a peer-to-peer network in which every peer is a P2Poolv2 mining node. Each node serves one or more locally connected mining rigs and acts as their gateway to the peer-to-peer network.
Each node runs the Stratum protocol to send work to its mining rigs and to collect shares from each rig every 3 seconds. This rapid frequency lets the node estimate the hashrate of each connected miner. Not all of these shares, however, meet the P2Poolv2 pool difficulty, which targets one share every 10 seconds. P2Poolv2 uses ASERT as the difficulty adjustment algorithm to hold that 10s share interval. See Stratum Server & Vardiff for details on the difficulty adjustment algorithm.
Nodes gossip the shares that meet the pool difficulty over the peer-to-peer network, and every node that receives a share validates it. See Share Validation for details.
The diagram below shows a peer-to-peer network of seven nodes, Node A to Node G. Several connections carry shares at once, because more than one node can find a share at the same time.
Every node thus holds a replica of the shares, and the nodes reach Nakamoto consensus on the state of the sharechain. Through this consensus, all nodes agree on the sharechain and on how many shares each miner mined at which difficulty. When a share arrives, each node uses this agreement to work out the rewards due to every miner, and verifies that the share’s bitcoin coinbase pays the expected reward distribution. See PPLNS Share Accounting for how the accounting is continuously audited.