Skip to content

Commit 3e31642

Browse files
committed
tapdb: read and write database asset transfer label
1 parent a0199e7 commit 3e31642

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

tapdb/assets_store.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,7 @@ func (a *AssetStore) LogPendingParcel(ctx context.Context,
24422442
HeightHint: int32(spend.AnchorTxHeightHint),
24432443
AnchorTxid: newAnchorTXID[:],
24442444
TransferTimeUnix: spend.TransferTime,
2445+
Label: sqlStr(spend.Label),
24452446
})
24462447
if err != nil {
24472448
return fmt.Errorf("unable to insert asset transfer: "+
@@ -3562,6 +3563,7 @@ func (a *AssetStore) QueryParcels(ctx context.Context,
35623563
ChainFees: dbAnchorTx.ChainFees,
35633564
Inputs: inputs,
35643565
Outputs: outputs,
3566+
Label: dbT.Label.String,
35653567
}
35663568

35673569
// Set the block height if the anchor is marked as

tapdb/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
// daemon.
2323
//
2424
// NOTE: This MUST be updated when a new migration is added.
25-
LatestMigrationVersion = 31
25+
LatestMigrationVersion = 32
2626
)
2727

2828
// MigrationTarget is a functional option that can be passed to applyMigrations
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Remove `label` column from table `asset_transfer`.
2+
ALTER TABLE asset_transfers DROP COLUMN label;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add a column `label` to table `asset_transfer`.
2+
ALTER TABLE asset_transfers ADD COLUMN label VARCHAR DEFAULT NULL;

tapdb/sqlc/models.go

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

tapdb/sqlc/queries/transfers.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ WITH target_txn(txn_id) AS (
55
WHERE txid = @anchor_txid
66
)
77
INSERT INTO asset_transfers (
8-
height_hint, anchor_txn_id, transfer_time_unix
8+
height_hint, anchor_txn_id, transfer_time_unix, label
99
) VALUES (
10-
@height_hint, (SELECT txn_id FROM target_txn), @transfer_time_unix
10+
@height_hint, (SELECT txn_id FROM target_txn), @transfer_time_unix, @label
1111
) RETURNING id;
1212

1313
-- name: InsertAssetTransferInput :exec
@@ -44,7 +44,7 @@ WHERE output_id = (SELECT output_id FROM target);
4444
-- name: QueryAssetTransfers :many
4545
SELECT
4646
id, height_hint, txns.txid, txns.block_hash AS anchor_tx_block_hash,
47-
transfer_time_unix
47+
transfer_time_unix, transfers.label
4848
FROM asset_transfers transfers
4949
JOIN chain_txns txns
5050
ON txns.txn_id = transfers.anchor_txn_id

tapdb/sqlc/schemas/generated_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ CREATE TABLE asset_transfers (
265265
anchor_txn_id BIGINT NOT NULL REFERENCES chain_txns(txn_id),
266266

267267
transfer_time_unix TIMESTAMP NOT NULL
268-
);
268+
, label VARCHAR DEFAULT NULL);
269269

270270
CREATE TABLE asset_witnesses (
271271
witness_id INTEGER PRIMARY KEY,

tapdb/sqlc/transfers.sql.go

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

0 commit comments

Comments
 (0)