# Algorithm of distribution of Hashrate between P2pool and XvB
## Objective
If the Hashrate (HR) is not enough to probably always have at least one share in the window PPLNS (WP), the HR will never be redirected to XvB node but always stay on p2pool node.
If no share is acquired, all HR will stay on p2pool node until there is one.
If HR is enough to probably always have at least one share in the (WP), the spare HR will be:
**Default mode**: in part given to XvB node to be in the most possible round type and keep in p2pool the rest of HR that will not impact the type of round (sHR for spared HR).
P2pool node (PN) local API show only found shares and not current. It is not also showing the current height block of p2pool.
Gupaxx process will check every minute when a new share is found, and how much time passed since the last. While verifying if mining on mini or main chain, it will calculate if the last share found is still valid.
This way Gupaxx will know if a share is currently in the window.
This method is only an estimation, a better way would be to know at which block the share is found and which block height the network is currently at. But P2pool API doesn't offer these information by API but by command.
Gupaxx will simply watch the values retrieved by Xmrig process.
### Switching HR from p2pool node to XvB node
The mHR is calculated depending on the sidechain the p2pool is mining on.
The XvB process will check every ten minutes the last 15 minutes average HR and decide when to switch (in seconds) for the ten next minutes. (first p2pool then XvB).
*Need to see the time for Xmrig takes to set the new settings by API.*
When the time to switch arrives, XvB process will send a request to Xmrig to change the node used.