Add hashrate_split config for distributing miners across pool accounts#59
Open
taserz wants to merge 2 commits into
Open
Add hashrate_split config for distributing miners across pool accounts#59taserz wants to merge 2 commits into
taserz wants to merge 2 commits into
Conversation
Adds a new top-level config option hashrate_split, which accepts a list
of sub-account names with percentage weights. When configured, incoming
miners are randomly assigned to one of the split pool accounts on
connect, with each account receiving roughly its target share of traffic.
Example config:
"hashrate_split": [
{"sub_account": "account_a", "percent": 70},
{"sub_account": "account_b", "percent": 30}
]
All listed pool servers are used for connectivity; only the sub-account
field in the pools array is ignored when splitting is active. Pool
connections for every split account are established upfront at startup.
The split is per-miner (not per-share), which is accurate at any
meaningful number of miners and requires no per-share job tracking.
Fixes btccom#36.
Unit tests verify PickSplitAccount distributes across two and three accounts within 2% of the configured percentages over 100k iterations, handles a single account, and works when weights don't sum to 100. The end-to-end test spins up a minimal mock stratum server, starts btcagent with a 70/30 split config, connects 200 mock miners, and confirms routing lands within 10% of the target percentages. A test hook (onSubAccountPick) on SessionManager captures routing decisions without requiring full share submission flow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #36.
Adds a
hashrate_splittop-level config option that distributes incoming miners across multiple pool sub-accounts by percentage weight. This is a transparent proxy-side operation — miners connect normally and the agent handles the routing internally.How it works
Each miner is assigned to a sub-account at connection time, chosen randomly with weights proportional to the configured percentages. Pool connections for all split accounts are established at startup. The split is per-miner rather than per-share, which gives accurate distribution at any reasonable number of miners without requiring per-share job tracking.
Config example
{ "multi_user_mode": false, "pools": [ ["us.ss.btc.com", 1800, ""], ["us.ss.btc.com", 443, ""], ["us.ss.btc.com", 3333, ""] ], "hashrate_split": [ {"sub_account": "account_a", "percent": 70}, {"sub_account": "account_b", "percent": 30} ] }The
sub_accountfield in each pool entry is ignored whenhashrate_splitis active. Percentages do not need to sum to 100 — if they don't, the split is proportional to the weights.Changes
Config.go: newSplitAccountstruct,HashrateSplit []SplitAccountfield,PickSplitAccount()weighted random selection method, startup logging of split configSessionManager.go: pre-creates anUpSessionManagerfor each split account at startup; overrides sub-account routing inaddDownSessionwhen splitting is activeUpSessionBTC.go/UpSessionETH.go: preserve the manager's assigned sub-account (the split account) instead of overwriting it with the pool config's sub-account when splitting is activeagent_conf.default.json: adds emptyhashrate_splitfield to the example config