2.7 KiB
2.7 KiB
Data Models and Schema
Storage Backend
- Database engine: SQLite.
- Default file path:
./data/dashboard.db. - Effective path is controlled by
DB_PATH.
Related references:
- Configuration values:
doc/environment.md - Persistence implementation:
app/db.py
Tables
node_settings
Single-row settings table used as the source of truth for RPC and SSH connectivity.
Schema fields:
id INTEGER PRIMARY KEY CHECK (id = 1)rpc_url TEXT NOT NULLrpc_username TEXT NOT NULLrpc_password TEXT NOT NULLrpc_wallet TEXT NOT NULLconfig_path TEXT NOT NULLssh_host TEXT NOT NULLssh_port INTEGER NOT NULLssh_username TEXT NOT NULLssh_password TEXT NOT NULLssh_key_path TEXT NOT NULLbitcoin_binary TEXT NOT NULLupdated_at TEXT NOT NULL(UTC ISO 8601 string)
Invariants:
- Exactly one logical settings record exists with
id = 1. save_settingsperforms an upsert.- Missing settings row is represented by in-code defaults.
metrics_history
Time-series table for chart data and historical dashboard views.
Schema fields:
ts INTEGER PRIMARY KEY(Unix timestamp, seconds)blocks INTEGER NOT NULLheaders INTEGER NOT NULLmempool_bytes INTEGER NOT NULLpeers INTEGER NOT NULL
Index:
idx_metrics_history_tsonts
Invariants:
- A timestamp has at most one row.
- Inserts on duplicate timestamp overwrite existing point.
- Returned history is chronological for UI consumption.
Retention and Limits
Retention behavior is enforced during each metric insert:
- Time retention: rows older than 30 days are deleted.
- Count retention: rows beyond the newest 20000 samples are deleted.
- Query limit input is clamped to
[1, 20000].
Metric Sampling Sources
A metric point is composed from RPC responses:
blocksandheadersfromgetblockchaininfomempool_bytesfromgetmempoolinfo.bytespeersfromgetnetworkinfo.connections
Points are written:
- On each
/api/dashboard/summaryrequest. - In a background sampler loop at configured interval.
Settings Defaults
Default values used when no persisted row exists:
rpc_url:http://127.0.0.1:8332rpc_username: empty stringrpc_password: empty stringrpc_wallet: empty stringconfig_path: empty stringssh_host: empty stringssh_port:22ssh_username: empty stringssh_password: empty stringssh_key_path: empty stringbitcoin_binary:bitcoindupdated_at: empty string
Data Consumers
/api/settingsand/api/settings(PUT) read and writenode_settings./api/dashboard/history*readsmetrics_history./api/dashboard/summaryand sampler thread writemetrics_history.
See doc/api.md for endpoint-level contracts.