Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- No-op: we don't want to re-wipe block_hash values.
8 changes: 8 additions & 0 deletions store/migrations/000003_fix_immutable_block_hash.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Repopulate block_hash on transactions that were wiped when transitioning to IMMUTABLE.
-- Joins through processed_blocks to ensure we use the canonical chain's block hash.
UPDATE transactions
SET block_hash = mp.block_hash
FROM merkle_paths mp
JOIN processed_blocks pb ON mp.block_hash = pb.block_hash AND pb.on_chain = 1
WHERE transactions.txid = mp.txid
AND transactions.block_hash IS NULL;
8 changes: 2 additions & 6 deletions store/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,16 @@ func (s *Store) UpdateStatus(ctx context.Context, status *models.TransactionStat
UPDATE transactions
SET status = ?,
timestamp = ?,
block_hash = ?,
extra_info = ?,
competing_txs = json_set(competing_txs, '$.' || ?, json('true'))
WHERE txid = ?
AND status NOT IN (%s)
`, strings.Join(placeholders, ","))

args = make([]interface{}, 0, 6+len(disallowed))
args = make([]interface{}, 0, 5+len(disallowed))
args = append(args,
status.Status,
status.Timestamp,
nullString(status.BlockHash),
nullString(status.ExtraInfo),
status.CompetingTxs[0],
status.TxID,
Expand All @@ -190,17 +188,15 @@ WHERE txid = ?
UPDATE transactions
SET status = ?,
timestamp = ?,
block_hash = ?,
extra_info = ?
WHERE txid = ?
AND status NOT IN (%s)
`, strings.Join(placeholders, ","))

args = make([]interface{}, 0, 5+len(disallowed))
args = make([]interface{}, 0, 4+len(disallowed))
args = append(args,
status.Status,
status.Timestamp,
nullString(status.BlockHash),
nullString(status.ExtraInfo),
status.TxID,
)
Expand Down
Loading