Record and display winning share difficulty on found blocks
Logmon now captures the share diff from ckpool's "Possible block solve" line preceding the confirmation and attaches it to the BlockEvent. Persisted as share_diff alongside height/hash/reward and rendered as a new column in the dashboard block history.
This commit is contained in:
@@ -12,11 +12,12 @@ import (
|
||||
// data if available. Hash and Reward are populated best-effort via the
|
||||
// RPC lookup scheduled right after the log line is seen.
|
||||
type BlockRecord struct {
|
||||
Height int64 `json:"height"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
RewardBT float64 `json:"reward_btc,omitempty"`
|
||||
FoundAt time.Time `json:"found_at"`
|
||||
Source string `json:"source"` // "logmon" for now; "zmq" later
|
||||
Height int64 `json:"height"`
|
||||
Hash string `json:"hash,omitempty"`
|
||||
RewardBT float64 `json:"reward_btc,omitempty"`
|
||||
FoundAt time.Time `json:"found_at"`
|
||||
Source string `json:"source"` // "logmon" for now; "zmq" later
|
||||
ShareDiff float64 `json:"share_diff,omitempty"`
|
||||
}
|
||||
|
||||
// IngestBlockEvents reads block events from the tailer and appends them
|
||||
@@ -31,9 +32,10 @@ func (a *Aggregator) IngestBlockEvents(ctx context.Context, events <-chan logmon
|
||||
return
|
||||
}
|
||||
rec := BlockRecord{
|
||||
Height: ev.Height,
|
||||
FoundAt: ev.SeenAt,
|
||||
Source: "logmon",
|
||||
Height: ev.Height,
|
||||
FoundAt: ev.SeenAt,
|
||||
Source: "logmon",
|
||||
ShareDiff: ev.ShareDiff,
|
||||
}
|
||||
// Best-effort enrich with hash + coinbase reward via bitcoind.
|
||||
// We look up the hash from height, then fetch the full block
|
||||
@@ -56,11 +58,12 @@ func (a *Aggregator) IngestBlockEvents(ctx context.Context, events <-chan logmon
|
||||
}
|
||||
if a.Store != nil {
|
||||
if err := a.Store.InsertBlock(store.Block{
|
||||
Height: rec.Height,
|
||||
Hash: rec.Hash,
|
||||
RewardBT: rec.RewardBT,
|
||||
FoundAt: rec.FoundAt,
|
||||
Source: rec.Source,
|
||||
Height: rec.Height,
|
||||
Hash: rec.Hash,
|
||||
RewardBT: rec.RewardBT,
|
||||
FoundAt: rec.FoundAt,
|
||||
Source: rec.Source,
|
||||
ShareDiff: rec.ShareDiff,
|
||||
}); err != nil {
|
||||
a.Log.Warn("block persist failed", "height", rec.Height, "err", err)
|
||||
}
|
||||
@@ -114,11 +117,12 @@ func (a *Aggregator) loadPersistedBlocks() {
|
||||
for i := len(rows) - 1; i >= 0; i-- {
|
||||
r := rows[i]
|
||||
recs = append(recs, BlockRecord{
|
||||
Height: r.Height,
|
||||
Hash: r.Hash,
|
||||
RewardBT: r.RewardBT,
|
||||
FoundAt: r.FoundAt,
|
||||
Source: r.Source,
|
||||
Height: r.Height,
|
||||
Hash: r.Hash,
|
||||
RewardBT: r.RewardBT,
|
||||
FoundAt: r.FoundAt,
|
||||
Source: r.Source,
|
||||
ShareDiff: r.ShareDiff,
|
||||
})
|
||||
}
|
||||
a.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user