Unify best-share semantics across leaderboard / miners / user page
BestShares read worker.bestdiff for its "Best (round)" column,
while MinersTable used client.bestdiff for online workers (and
worker.bestdiff only as a fallback for offline ones). ckpool
resets *both* fields in reset_bestshares() when the pool finds a
block, but reconnect / timing can leave them briefly divergent,
so the same worker could show different values in the two tables.
Switch every "session best" display to the same computation:
max(client.bestdiff, worker.bestdiff)
…picking whichever is currently higher. Relabel the column from
"Best (round)" to "Best (session)" in MinersTable, BestShares, and
UserDetailPage so the meaning matches the value. UserDetailPage's
per-user summary tile used to show the user's round-best as a
sub-line; drop it, since it contradicts the "session" framing at
the row level.
Net effect: scroll between the leaderboard and the miners table
and the same worker's best-share number stays put.
This commit is contained in:
@@ -1,18 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { snap } from "../stores/snapshot.svelte";
|
||||
import { formatDifficulty } from "../format";
|
||||
import type { StratumClient } from "../types";
|
||||
|
||||
// Top 10 workers by all-time best share. `bestever` requires the
|
||||
// Kamado ckpool patch (0001-expose-bestever-in-runtime-json.patch)
|
||||
// — on an unpatched ckpool it will be zero everywhere and we fall
|
||||
// back to the current round's best diff.
|
||||
// Join client data into worker rows so the "session best" column
|
||||
// matches what the Miners table renders for the same worker.
|
||||
// ckpool's reset_bestshares() zeroes both worker.best_diff and
|
||||
// client.best_diff when the pool finds a block, but timing or
|
||||
// reconnect can leave the two briefly divergent — take the larger
|
||||
// of the two to stay consistent with the Miners table.
|
||||
const rows = $derived.by(() => {
|
||||
const ws = snap.data?.workers ?? [];
|
||||
const enriched = ws.map((w) => ({
|
||||
worker: w.worker,
|
||||
bestRound: w.bestdiff,
|
||||
bestEver: w.bestever || w.bestdiff,
|
||||
}));
|
||||
const cs = snap.data?.clients ?? [];
|
||||
const clientByWorker = new Map<string, StratumClient>();
|
||||
for (const c of cs) {
|
||||
const wname = c.workername || `${c.address}.unnamed`;
|
||||
clientByWorker.set(wname, c);
|
||||
}
|
||||
const enriched = ws.map((w) => {
|
||||
const c = clientByWorker.get(w.worker);
|
||||
const sessionBest = Math.max(c?.bestdiff ?? 0, w.bestdiff);
|
||||
return {
|
||||
worker: w.worker,
|
||||
sessionBest,
|
||||
bestEver: w.bestever || sessionBest,
|
||||
};
|
||||
});
|
||||
enriched.sort((a, b) => b.bestEver - a.bestEver);
|
||||
return enriched.slice(0, 10);
|
||||
});
|
||||
@@ -28,7 +41,7 @@
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Worker</th>
|
||||
<th class="num">Best (round)</th>
|
||||
<th class="num">Best (session)</th>
|
||||
<th class="num">Best (ever)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -37,7 +50,7 @@
|
||||
<tr>
|
||||
<td>{i + 1}</td>
|
||||
<td class="mono">{r.worker}</td>
|
||||
<td class="num">{formatDifficulty(r.bestRound)}</td>
|
||||
<td class="num">{formatDifficulty(r.sessionBest)}</td>
|
||||
<td class="num">{formatDifficulty(r.bestEver)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
||||
Reference in New Issue
Block a user