Skip to content

Commit e575d79

Browse files
committed
tapdb: add supply syncer log table
Add a new table to track the latest synced block height for the supply syncer. This enables resuming syncing from a consistent point and helps monitor the current sync state.
1 parent 805063c commit e575d79

File tree

5 files changed

+40
-1
lines changed

5 files changed

+40
-1
lines changed

tapdb/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const (
2424
// daemon.
2525
//
2626
// NOTE: This MUST be updated when a new migration is added.
27-
LatestMigrationVersion = 43
27+
LatestMigrationVersion = 44
2828
)
2929

3030
// DatabaseBackend is an interface that contains all methods our different
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Drop the supply_syncer_log table and its index.
2+
DROP INDEX IF EXISTS supply_syncer_log_group_key_idx;
3+
DROP TABLE IF EXISTS supply_syncer_log;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Table to track the latest synced block height for supply syncers per asset
2+
-- group.
3+
CREATE TABLE supply_syncer_log (
4+
id INTEGER PRIMARY KEY,
5+
6+
-- The tweaked group key identifying the asset group this sync log belongs
7+
-- to. This should match the group_key format used in universe_supply_roots.
8+
group_key BLOB UNIQUE NOT NULL CHECK(length(group_key) = 33),
9+
10+
-- The latest block height that has been successfully synced for this asset
11+
-- group.
12+
latest_sync_block_height INTEGER NOT NULL
13+
);
14+
15+
-- Add index for frequent lookups by group key.
16+
CREATE INDEX supply_syncer_log_group_key_idx ON supply_syncer_log(group_key);

tapdb/sqlc/models.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tapdb/sqlc/schemas/generated_schema.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,20 @@ CREATE INDEX supply_commitments_chain_txn_id_idx ON supply_commitments(chain_txn
881881

882882
CREATE INDEX supply_commitments_group_key_idx ON supply_commitments(group_key);
883883

884+
CREATE TABLE supply_syncer_log (
885+
id INTEGER PRIMARY KEY,
886+
887+
-- The tweaked group key identifying the asset group this sync log belongs
888+
-- to. This should match the group_key format used in universe_supply_roots.
889+
group_key BLOB UNIQUE NOT NULL CHECK(length(group_key) = 33),
890+
891+
-- The latest block height that has been successfully synced for this asset
892+
-- group.
893+
latest_sync_block_height INTEGER NOT NULL
894+
);
895+
896+
CREATE INDEX supply_syncer_log_group_key_idx ON supply_syncer_log(group_key);
897+
884898
CREATE TABLE supply_update_events (
885899
event_id INTEGER PRIMARY KEY,
886900

0 commit comments

Comments
 (0)