A P2Poolv2 node has two components: a Stratum server that miners connect to, and a controller node that runs share accounting and talks to the other nodes in the pool.
@startuml
skinparam componentStyle rectangle
actor "Miner Rigs" as miner
node "P2Poolv2 node" {
component "Stratum server" as stratum
component "Controller node" as controller
database "Share store" as store
}
cloud "Other P2Poolv2 nodes" as peers
component "bitcoind" as bitcoind
miner --> stratum : shares
stratum --> controller : shares
controller --> stratum : coinbase,\ndifficulty
controller --> store
controller <--> peers : pool shares
bitcoind --> controller : block templates
@enduml
-
Listens to blockchain events from bitcoind.
-
Builds work for mining devices using the Stratum protocol and the details received from the P2Poolv2 controller node.
-
Receives shares found by mining devices and sends them to the controller node.
-
Accepts shares from the Stratum server.
-
Runs share accounting on the last N shares on the sharechain to decide how much each miner is paid.
-
Builds a coinbase from that accounting.
-
Tells the Stratum server the current pool difficulty and coinbase.
-
Validates that shares received from peers meet the pool difficulty and pay the expected payouts derived from the sharechain accounting.
In the figure shares means the shares found by the mining rig that
meet the local vardiff. In contrast, pool shares are the shares that
also meet the current pool difficulty. Only the pool shares are
transmitted to the other P2Poolv2 nodes.
In the source code, the Stratum server and the controller node share a
single crate, p2poolv2_lib.