Skip to content

Commit ed5b0c0

Browse files
committed
fix: adding index_block_hash checks to other tables when micro-orphaning
1 parent ea4d801 commit ed5b0c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/datastore/postgres-store.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ export class PgDataStore
12311231
SET microblock_canonical = false, canonical = $1
12321232
WHERE parent_index_block_hash = $2
12331233
AND microblock_hash = ANY($3)
1234-
AND index_block_hash = $4
1234+
AND (index_block_hash = $4 OR index_block_hash = '\\x'::bytea)
12351235
RETURNING tx_id, microblock_hash, block_hash
12361236
`,
12371237
[
@@ -1252,6 +1252,7 @@ export class PgDataStore
12521252
isCanonical,
12531253
hexToBuffer(parentIndexBlockHash),
12541254
orphanedMicroblocks.map(mb => hexToBuffer(mb)),
1255+
hexToBuffer(indexBlockHash),
12551256
orphanedMicroblockTxs.map(txId => hexToBuffer(txId)),
12561257
];
12571258
for (const associatedTableName of TX_METADATA_TABLES) {
@@ -1261,7 +1262,8 @@ export class PgDataStore
12611262
SET microblock_canonical = false, canonical = $1
12621263
WHERE parent_index_block_hash = $2
12631264
AND microblock_hash = ANY($3)
1264-
AND tx_id = ANY($4)
1265+
AND (index_block_hash = $4 OR index_block_hash = '\\x'::bytea)
1266+
AND tx_id = ANY($5)
12651267
`,
12661268
orphanedAssociatedTableParams
12671269
);

0 commit comments

Comments
 (0)