Adds real-time block detection via ckpool log tailing and a push channel for the upcoming Svelte UI, all stdlib-only: - logmon.Tailer follows ckpool.log with rotation/truncation survival (inode + size tracking) and parses "Solved and confirmed block N" into BlockEvent values. - state.Aggregator grows a 256-entry block ring, an OnRefresh hook, and IngestBlockEvents which best-effort enriches events with the block hash via bitcoind getblockhash. - httpapi.Hub implements RFC 6455 from scratch (SHA1 handshake, unmasked text frames out, masked frames in, ping keepalive, per-client write mutex, slow-client drop) so we don't pull in a ws dependency before we can go mod tidy. - New routes: GET /api/blocks and GET /api/ws. Snapshot pushes fire on every poll tick and immediately on block-solve. ZMQ hashblock subscription and SQLite persistence are deferred to Phase 2b.5 once the s9pk packaging repo exists and we have a real build environment for adding Go deps.
18 lines
322 B
Go
18 lines
322 B
Go
//go:build unix
|
|
|
|
package logmon
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// inodeOf returns the inode number for a FileInfo on unix systems, or 0
|
|
// if the underlying stat is unavailable. Used to detect log rotation.
|
|
func inodeOf(fi os.FileInfo) uint64 {
|
|
if st, ok := fi.Sys().(*syscall.Stat_t); ok {
|
|
return st.Ino
|
|
}
|
|
return 0
|
|
}
|