File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1706,6 +1706,10 @@ export class PgDataStore
1706
1706
) ;
1707
1707
}
1708
1708
1709
+ // TODO: [bug] This is can end up with incorrect canonical state due to missing the `index_block_hash` column
1710
+ // which is required for the way micro-reorgs are handled. Queries against this table can work around the
1711
+ // bug by using the `txs` table canonical state in the JOIN condition.
1712
+
1709
1713
// Update `principal_stx_txs`
1710
1714
await client . query (
1711
1715
`UPDATE principal_stx_txs
@@ -5540,15 +5544,17 @@ export class PgDataStore
5540
5544
WITH stx_txs AS (
5541
5545
SELECT tx_id, ${ countOverColumn ( ) }
5542
5546
FROM principal_stx_txs
5543
- WHERE principal = $1 AND ${ blockCond } AND canonical = TRUE AND microblock_canonical = TRUE
5547
+ WHERE principal = $1 AND ${ blockCond }
5544
5548
ORDER BY block_height DESC, microblock_sequence DESC, tx_index DESC
5545
5549
LIMIT $2
5546
5550
OFFSET $3
5547
5551
)
5548
5552
SELECT ${ txColumns ( ) } , ${ abiColumn ( ) } , count
5549
5553
FROM stx_txs
5550
- INNER JOIN txs USING (tx_id)
5551
- WHERE canonical = TRUE AND microblock_canonical = TRUE
5554
+ INNER JOIN txs
5555
+ ON stx_txs.tx_id = txs.tx_id
5556
+ AND txs.canonical = TRUE
5557
+ AND txs.microblock_canonical = TRUE
5552
5558
` ,
5553
5559
[ args . stxAddress , args . limit , args . offset , args . blockHeight ]
5554
5560
) ;
You can’t perform that action at this time.
0 commit comments