Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ per the process in [`docs/releasing.md`](docs/releasing.md).
a space check" fallback was previously unreachable under `set -e`) (#127).
- `pithead doctor` now exits non-zero when a critical check FAILS, so it can be used as a
cron/CI/monitoring health gate (it previously always exited 0); warnings alone still exit 0 (#127).
- Dashboard P2Pool pool-type detection (Main/Mini/Nano) now matches the peer's port exactly
instead of as a substring of the whole peer string, so a peer on an unrelated port that merely
contains the digits can't misclassify the sidechain (which drives block-time and the PPLNS
window the XvB controller uses) (#142).

### Security

Expand Down
13 changes: 9 additions & 4 deletions build/dashboard/mining_dashboard/collector/pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ def detect_pool_type(peers):
if not peers:
return "Unknown"

# Match the port exactly (the last colon-segment), not as a substring of the whole peer
# string — an IP that merely contains the port digits (e.g. "37.88.9.1:18080") would
# otherwise be miscounted, and pool type drives block_time / the PPLNS-window duration the
# XvB controller relies on (#142).
by_port = {"37889": "Main", "37888": "Mini", "37890": "Nano"}
for p in peers:
if "37889" in p: counts["Main"] += 1
elif "37888" in p: counts["Mini"] += 1
elif "37890" in p: counts["Nano"] += 1
pool = by_port.get(str(p).rsplit(":", 1)[-1])
if pool:
counts[pool] += 1

winner = max(counts, key=counts.get)
return winner if counts[winner] > 0 else "Unknown"

Expand Down
8 changes: 8 additions & 0 deletions build/dashboard/tests/collector/test_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def test_majority_wins(self):
def test_unknown_ports(self):
assert detect_pool_type(["1.1.1.1:9999"]) == "Unknown"

def test_port_matched_exactly_not_as_substring(self):
# The port must match exactly (last colon-segment), not as a substring of the peer string.
# Each of these returned a WRONG pool under the old `"37889" in p` substring check (#142).
assert detect_pool_type(["1.1.1.1:137889"]) == "Unknown" # old: contained "37889" -> Main
assert detect_pool_type(["1.1.1.1:378880"]) == "Unknown" # old: contained "37888" -> Mini
assert detect_pool_type(["1.1.1.1:37889x"]) == "Unknown" # trailing junk -> not the Main port
assert detect_pool_type(["1.1.1.1:37888"]) == "Mini" # exact port still detected


def _read_json_map(mapping):
"""Return a side_effect that maps a stats path to a fixture dict."""
Expand Down
Loading