Skip to content

Add hashrate_split config for distributing miners across pool accounts#59

Open
taserz wants to merge 2 commits into
btccom:masterfrom
taserz:feat/hashrate-split
Open

Add hashrate_split config for distributing miners across pool accounts#59
taserz wants to merge 2 commits into
btccom:masterfrom
taserz:feat/hashrate-split

Conversation

@taserz

@taserz taserz commented May 13, 2026

Copy link
Copy Markdown

Fixes #36.

Adds a hashrate_split top-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_account field in each pool entry is ignored when hashrate_split is active. Percentages do not need to sum to 100 — if they don't, the split is proportional to the weights.

Changes

  • Config.go: new SplitAccount struct, HashrateSplit []SplitAccount field, PickSplitAccount() weighted random selection method, startup logging of split config
  • SessionManager.go: pre-creates an UpSessionManager for each split account at startup; overrides sub-account routing in addDownSession when splitting is active
  • UpSessionBTC.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 active
  • agent_conf.default.json: adds empty hashrate_split field to the example config

taserz added 2 commits May 13, 2026 13:36
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split Hashrate %

1 participant