Skip to content

Commit 245a77b

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 e575d79 commit 245a77b

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- name: UpsertSupplySyncerLog :exec
2+
INSERT INTO supply_syncer_log (group_key, latest_sync_block_height)
3+
VALUES (@group_key, @latest_sync_block_height)
4+
ON CONFLICT (group_key)
5+
DO UPDATE SET latest_sync_block_height = EXCLUDED.latest_sync_block_height;
6+
7+
-- name: FetchSupplySyncerLog :one
8+
SELECT group_key, latest_sync_block_height
9+
FROM supply_syncer_log
10+
WHERE group_key = @group_key;

tapdb/sqlc/supply_syncer.sql.go

Lines changed: 45 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)