File tree 1 file changed +18
-16
lines changed
1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -1809,22 +1809,24 @@ export class PgWriteStore extends PgStore {
1809
1809
}
1810
1810
1811
1811
async dropMempoolTxs ( { status, txIds } : { status : DbTxStatus ; txIds : string [ ] } ) : Promise < void > {
1812
- const updateResults = await this . sql < { tx_id : string } [ ] > `
1813
- WITH pruned AS (
1814
- UPDATE mempool_txs
1815
- SET pruned = TRUE, status = ${ status }
1816
- WHERE tx_id IN ${ this . sql ( txIds ) } AND pruned = FALSE
1817
- RETURNING tx_id
1818
- ),
1819
- count_update AS (
1820
- UPDATE chain_tip SET
1821
- mempool_tx_count = mempool_tx_count - (SELECT COUNT(*) FROM pruned),
1822
- mempool_updated_at = NOW()
1823
- )
1824
- SELECT tx_id FROM pruned
1825
- ` ;
1826
- for ( const txId of updateResults . map ( r => r . tx_id ) ) {
1827
- await this . notifier ?. sendTx ( { txId } ) ;
1812
+ for ( const batch of batchIterate ( txIds , INSERT_BATCH_SIZE ) ) {
1813
+ const updateResults = await this . sql < { tx_id : string } [ ] > `
1814
+ WITH pruned AS (
1815
+ UPDATE mempool_txs
1816
+ SET pruned = TRUE, status = ${ status }
1817
+ WHERE tx_id IN ${ this . sql ( batch ) } AND pruned = FALSE
1818
+ RETURNING tx_id
1819
+ ),
1820
+ count_update AS (
1821
+ UPDATE chain_tip SET
1822
+ mempool_tx_count = mempool_tx_count - (SELECT COUNT(*) FROM pruned),
1823
+ mempool_updated_at = NOW()
1824
+ )
1825
+ SELECT tx_id FROM pruned
1826
+ ` ;
1827
+ for ( const txId of updateResults . map ( r => r . tx_id ) ) {
1828
+ await this . notifier ?. sendTx ( { txId } ) ;
1829
+ }
1828
1830
}
1829
1831
}
1830
1832
You can’t perform that action at this time.
0 commit comments