@@ -850,7 +850,6 @@ export class PgDataStore
850
850
const { orphanedMicroblocks } = await this . findUnanchoredMicroblocksAtChainTip (
851
851
client ,
852
852
currentMicroblockTip . parent_index_block_hash ,
853
- '' ,
854
853
currentMicroblockTip
855
854
) ;
856
855
if ( orphanedMicroblocks . length > 0 ) {
@@ -859,7 +858,6 @@ export class PgDataStore
859
858
const { orphanedMicroblockTxs } = await this . handleMicroOrphan (
860
859
client ,
861
860
currentMicroblockTip . parent_index_block_hash ,
862
- '' ,
863
861
true ,
864
862
orphanedMicroblocks
865
863
) ;
@@ -917,14 +915,11 @@ export class PgDataStore
917
915
`
918
916
SELECT microblock_hash
919
917
FROM microblocks
920
- WHERE parent_index_block_hash = $1
921
- AND microblock_hash = ANY($2)
922
- AND (index_block_hash = $3 OR index_block_hash = '\\x'::bytea)
918
+ WHERE parent_index_block_hash = $1 AND microblock_hash = ANY($2)
923
919
` ,
924
920
[
925
921
hexToBuffer ( data . block . parent_index_block_hash ) ,
926
922
data . microblocks . map ( mb => hexToBuffer ( mb . microblock_hash ) ) ,
927
- hexToBuffer ( data . block . index_block_hash ) ,
928
923
]
929
924
) ;
930
925
const existingMicroblockHashes = new Set (
@@ -981,15 +976,13 @@ export class PgDataStore
981
976
} = await this . findUnanchoredMicroblocksAtChainTip (
982
977
client ,
983
978
data . block . parent_index_block_hash ,
984
- data . block . index_block_hash ,
985
979
acceptedMicroblockTip
986
980
) ;
987
981
988
982
if ( orphanedMicroblocks . length > 0 ) {
989
983
const { orphanedMicroblockTxs } = await this . handleMicroOrphan (
990
984
client ,
991
985
data . block . parent_index_block_hash ,
992
- data . block . index_block_hash ,
993
986
isCanonical ,
994
987
orphanedMicroblocks
995
988
) ;
@@ -1011,15 +1004,13 @@ export class PgDataStore
1011
1004
SET microblock_canonical = true, canonical = $1, index_block_hash = $2, block_hash = $3
1012
1005
WHERE parent_index_block_hash = $4
1013
1006
AND microblock_hash = ANY($5)
1014
- AND (index_block_hash = $6 OR index_block_hash = '\\x'::bytea)
1015
1007
` ,
1016
1008
[
1017
1009
isCanonical ,
1018
1010
hexToBuffer ( data . block . index_block_hash ) ,
1019
1011
hexToBuffer ( data . block . block_hash ) ,
1020
1012
hexToBuffer ( data . block . parent_index_block_hash ) ,
1021
1013
acceptedMicroblocks . map ( mb => hexToBuffer ( mb ) ) ,
1022
- hexToBuffer ( data . block . index_block_hash ) ,
1023
1014
]
1024
1015
) ;
1025
1016
// Note: this assumes the stacks-node will never send the same combination of (microblock_hash, parent_index_block_hash) more than once.
@@ -1036,7 +1027,6 @@ export class PgDataStore
1036
1027
UPDATE txs
1037
1028
SET microblock_canonical = true, canonical = $1, index_block_hash = $2, block_hash = $3, burn_block_time = $4
1038
1029
WHERE parent_index_block_hash = $5
1039
- AND (index_block_hash = $2 OR index_block_hash = '\\x'::bytea)
1040
1030
AND microblock_hash = ANY($6)
1041
1031
RETURNING tx_id, microblock_hash
1042
1032
` ,
@@ -1199,7 +1189,6 @@ export class PgDataStore
1199
1189
async handleMicroOrphan (
1200
1190
client : ClientBase ,
1201
1191
parentIndexBlockHash : string ,
1202
- indexBlockHash : string ,
1203
1192
isCanonical : boolean ,
1204
1193
orphanedMicroblocks : string [ ]
1205
1194
) : Promise < { orphanedMicroblockTxs : string [ ] } > {
@@ -1210,13 +1199,8 @@ export class PgDataStore
1210
1199
SET microblock_canonical = false
1211
1200
WHERE parent_index_block_hash = $1
1212
1201
AND microblock_hash = ANY($2)
1213
- AND (index_block_hash = $3 OR index_block_hash = '\\x'::bytea)
1214
1202
` ,
1215
- [
1216
- hexToBuffer ( parentIndexBlockHash ) ,
1217
- orphanedMicroblocks . map ( mb => hexToBuffer ( mb ) ) ,
1218
- hexToBuffer ( indexBlockHash ) ,
1219
- ]
1203
+ [ hexToBuffer ( parentIndexBlockHash ) , orphanedMicroblocks . map ( mb => hexToBuffer ( mb ) ) ]
1220
1204
) ;
1221
1205
if ( orphanMicroblocksQuery . rowCount !== orphanedMicroblocks . length ) {
1222
1206
throw new Error ( `Unexpected number of rows updated when setting microblock_canonical` ) ;
@@ -1231,14 +1215,12 @@ export class PgDataStore
1231
1215
SET microblock_canonical = false, canonical = $1
1232
1216
WHERE parent_index_block_hash = $2
1233
1217
AND microblock_hash = ANY($3)
1234
- AND index_block_hash = $4
1235
- RETURNING tx_id, microblock_hash, block_hash
1218
+ RETURNING tx_id, microblock_hash
1236
1219
` ,
1237
1220
[
1238
1221
isCanonical ,
1239
1222
hexToBuffer ( parentIndexBlockHash ) ,
1240
1223
orphanedMicroblocks . map ( mb => hexToBuffer ( mb ) ) ,
1241
- hexToBuffer ( indexBlockHash ) ,
1242
1224
]
1243
1225
) ;
1244
1226
orphanedMbTxsQuery . rows . forEach ( row => {
@@ -1280,7 +1262,6 @@ export class PgDataStore
1280
1262
async findUnanchoredMicroblocksAtChainTip (
1281
1263
client : ClientBase ,
1282
1264
parentIndexBlockHash : string ,
1283
- indexBlockHash : string ,
1284
1265
microblockChainTip : DbMicroblock | undefined
1285
1266
) : Promise < { acceptedMicroblocks : string [ ] ; orphanedMicroblocks : string [ ] } > {
1286
1267
// Get any microblocks that this anchor block is responsible for accepting or rejecting.
@@ -1291,9 +1272,8 @@ export class PgDataStore
1291
1272
SELECT ${ MICROBLOCK_COLUMNS }
1292
1273
FROM microblocks
1293
1274
WHERE parent_index_block_hash = $1
1294
- AND (index_block_hash = $2 OR index_block_hash = '\\x'::bytea)
1295
1275
` ,
1296
- [ hexToBuffer ( parentIndexBlockHash ) , hexToBuffer ( indexBlockHash ) ]
1276
+ [ hexToBuffer ( parentIndexBlockHash ) ]
1297
1277
) ;
1298
1278
const candidateMicroblocks = mbQuery . rows . map ( row => this . parseMicroblockQueryResult ( row ) ) ;
1299
1279
@@ -2775,8 +2755,8 @@ export class PgDataStore
2775
2755
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19,
2776
2756
$20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37
2777
2757
)
2778
- ON CONFLICT ON CONSTRAINT unique_tx_id_index_block_hash
2779
- DO NOTHING
2758
+ -- ON CONFLICT ON CONSTRAINT unique_tx_id_index_block_hash
2759
+ -- DO NOTHING
2780
2760
` ,
2781
2761
[
2782
2762
hexToBuffer ( tx . tx_id ) ,
0 commit comments