Skip to content

Commit 2a41662

Browse files
committed
tapdb: add SQL queries for supply syncer log
Add the queries FetchSupplySyncerLog and UpsertSupplySyncerLog to interact with the supply syncer log table.
1 parent 7b6a0d3 commit 2a41662

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

tapdb/sqlc/querier.go

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

tapdb/sqlc/queries/supply_syncer.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- name: UpsertSupplySyncerLog :exec
2+
INSERT INTO supply_syncer_log (group_key, max_fetched_block_height, max_inserted_block_height)
3+
VALUES (@group_key, @max_fetched_block_height, @max_inserted_block_height)
4+
ON CONFLICT (group_key) DO UPDATE SET
5+
max_fetched_block_height = COALESCE(@max_fetched_block_height, supply_syncer_log.max_fetched_block_height),
6+
max_inserted_block_height = COALESCE(@max_inserted_block_height, supply_syncer_log.max_inserted_block_height);
7+
8+
-- name: FetchSupplySyncerLog :one
9+
SELECT group_key, max_fetched_block_height, max_inserted_block_height
10+
FROM supply_syncer_log
11+
WHERE group_key = @group_key;

tapdb/sqlc/supply_syncer.sql.go

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

tapdb/universe.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ type BaseUniverseStore interface {
138138
QuerySupplyLeavesByHeight(ctx context.Context,
139139
arg QuerySupplyLeavesByHeightParams) (
140140
[]sqlc.QuerySupplyLeavesByHeightRow, error)
141+
142+
// UpsertSupplySyncerLog upserts a supply syncer log entry to track the
143+
// latest synced block height for an asset group.
144+
UpsertSupplySyncerLog(ctx context.Context,
145+
arg sqlc.UpsertSupplySyncerLogParams) error
146+
147+
// FetchSupplySyncerLog fetches the supply syncer log entry for a given
148+
// asset group.
149+
FetchSupplySyncerLog(ctx context.Context,
150+
groupKey []byte) (sqlc.FetchSupplySyncerLogRow, error)
141151
}
142152

143153
// getUniverseTreeSum retrieves the sum of a universe tree specified by its

0 commit comments

Comments
 (0)