-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
Implement the SQLite-based storage layer (pkg/store/) as defined in the design doc. This is the foundational persistence layer all other components depend on.
Schema
CREATE TABLE sync_state (
id INTEGER PRIMARY KEY CHECK (id = 1),
last_synced_height INTEGER NOT NULL DEFAULT 0,
start_height INTEGER NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE headers (
height INTEGER PRIMARY KEY,
hash BLOB NOT NULL,
data_hash BLOB NOT NULL,
raw_header BLOB NOT NULL,
time TIMESTAMP NOT NULL
);
CREATE TABLE blobs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
height INTEGER NOT NULL,
namespace BLOB NOT NULL,
commitment BLOB NOT NULL,
data BLOB NOT NULL,
share_version INTEGER NOT NULL,
signer BLOB,
blob_index INTEGER NOT NULL,
UNIQUE(height, namespace, commitment)
);
CREATE INDEX idx_blobs_ns_height ON blobs(namespace, height);
CREATE TABLE namespaces (
namespace BLOB PRIMARY KEY,
name TEXT,
enabled BOOLEAN DEFAULT TRUE
);Requirements
Storeinterface inpkg/store/store.go- SQLite implementation in
pkg/store/sqlite.go - Schema migrations (embed SQL via
embedpackage) - Methods: InsertHeader, InsertBlobs, GetBlobsByHeight, GetBlob (by height+ns+commitment), GetHeader, GetSyncState, UpdateSyncState
- WAL mode enabled for concurrent read/write
- Connection pooling via
database/sql - Unit tests with in-memory SQLite
References
- Design doc:
test_plan.md— Storage Design section
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels