Repository navigation
Description
What's the problem
Part of #2476. Owner priority (2026-10-27): build the opt-in donation feature now, shipping dark. Nothing records a third destination, and nothing in the API would show one:
- The only donation series,
xvb_history, is written inside the XvB stats sync (dashboard/mining_dashboard/service/data_xvb_sync.py:56-71), which the caller runs only when XvB is enabled (:48). It cannot describe a project slice when XvB is off, and itsdonation_fractioncolumn means the XvB slice. - Hashrate is attributed per poll by the mode label:
is_xvb = "XVB" in current_mode(service/data_service.py:508-510), and the chart palette keys on the substringsSplitandXVB(web/views/series_views.py:193-200). A project slice's hashrate is therefore counted as P2Pool hashrate; the new record is the only truthful source for "how much went to the project". /api/statecarries no donation block, so the settings section, the Earnings line, the chart band and the Activity entries (UI children) have nothing to read.
Add, in new or small files only:
- A
donation_historytable:(ts REAL, routed_fraction REAL, mode TEXT, ok INTEGER), createdIF NOT EXISTSinservice/storage_schema.pybesidexvb_history(:209-214), additive with no_migrate_dbentry, 30-day retention likeXVB_HISTORY_RETENTION_SEC(service/telemetry_store.py:31). Addadd_donation_historyandget_donation_historytoTelemetryStoreMixin(telemetry_store.py:38-85is the pattern; the mixin is already part ofStateManager, and the file is 171 lines). The controller ({{A8}}) writes one row per cycle, independent ofENABLE_XVB. - A donation state record (debt in seconds, last slice time, status, endpoint-down-since) stored through the existing
get_kvandset_kv(service/storage_service.py:709-736), JSON under one key. - A
donationblock on/api/state:available(from {{A2}}),enabled,percent,status(off,idle,donating,fallback,reduced),recipient,address,route(torordirect),minutes_today,slice_ends_at(a timestamp while donating, else null),reduced_percent(the effective percentage whenstatusisreduced, else null),endpoint_down_since(null unless in fallback) andestimate(null until {{A11}}); plus adonation_historyseries through the same range and window helpers asbuild_xvb_history(series_views.py:179-185). Put the builder in a new moduleweb/views/donation_views.py. web/views/views.pyis at its 426-line ceiling andweb/server.pyat 630,service/storage_service.pyat 785. Wire the block intobuild_state(views.py:380-389) by replacing the stale three-line comment at:380-382with the two new entries, so the file does not grow.
What it impacts
The state payload gains one block and one series. With the feature unavailable the block is {"available": false} and no row is written. Clients that ignore unknown keys are unaffected. Existing xvb_history consumers and the 5-window history columns are not changed.
How I found it
Read-only scan of origin/develop-v2.1.0 at 02852bd on 2026-10-27 from the paths above. Nothing was executed. Unknown: whether any frontend fixture or contract test enumerates the exact /api/state key set (the dashboard tests/frontend/fixtures/state.json is the first place to check); and whether the chart should attribute project-slice hashrate away from P2Pool in the 5-window history (left out here on purpose; the new series drives the chart band).
How important is it
Medium. Every visible half of the feature reads this; the controller needs somewhere to persist the debt so a restart does not lose it.
Acceptance criteria
- New tests (
dashboard/tests/service/test_storage_donation.py,dashboard/tests/web/views/test_donation_views.py): rows round-trip throughadd_donation_historyandget_donation_history; rows older than 30 days are pruned; a fresh and an existing database both open with the table present and no migration noise (pattern:dashboard/tests/service/test_storage_xvb.py). - The state record round-trips through
get_kvas JSON and survives aStateManagerrestart; a corrupt value reads as the default and logs once. - The
donationblock: unavailable constants give{"available": false}and no other key; available and disabled givesstatus: "off"; the other statuses are produced from the stored record in a table test; the address and recipient come from the constants loader, never from config. donation_historyis written whenENABLE_XVBis false.views.py,server.pyandstorage_service.pydo not grow (the file-budget check passes with no ceiling raised).make test,make test-patch-coverage(90 % of changed lines) andmake lint-file-budgetpass. No new explanatory code comments.
Possible solutions
- Extend
TelemetryStoreMixin(recommended: the sanctioned seam, no new path to the DB handle). - A new mixin file added to the
StateManagerbase list (service/storage_service.py:80-82); that file is at its ceiling, so this needs an equal deletion in the same file. - Reuse
xvb_historywith a new column: rejected, because it is only written when XvB is on.
Part of #2476. Depends on {{A1}} and {{A2}}.
Activity
pithead-developer commentedon Nov 16, 2026
Blocked on #3695.
Dependency marker for the dashboard. The native blocked-by links on this issue already name these open blockers, and the tick removes
blockedwhen every one of them closes.pithead-architect commentedon Nov 20, 2026
Owner ruling, 2026-11-20: "we can dark release it ahead so we can spot issues in logs before making a proper ui for it".
The backend ships in v2.0.7 and v2.0.8 with no UI, so the logs are the only way to see it working. One acceptance criterion is added to this issue:
donation:): slice start and end, the route chosen (tor or direct), fallback to P2Pool, endpoint errors and the cost estimate. These lines appear in the dashboard log and in the support bundle, with addresses redacted by the existing redactors. No UI is required.