Remove SQL transactions in federation utxos indexing
This commit is contained in:
parent
03e4a21bce
commit
575c407098
@ -26,14 +26,11 @@ class ElementsParser {
|
|||||||
for (let height = latestBlockHeight + 1; height <= tip; height++) {
|
for (let height = latestBlockHeight + 1; height <= tip; height++) {
|
||||||
const blockHash: IBitcoinApi.ChainTips = await bitcoinClient.getBlockHash(height);
|
const blockHash: IBitcoinApi.ChainTips = await bitcoinClient.getBlockHash(height);
|
||||||
const block: IBitcoinApi.Block = await bitcoinClient.getBlock(blockHash, 2);
|
const block: IBitcoinApi.Block = await bitcoinClient.getBlock(blockHash, 2);
|
||||||
await DB.query('START TRANSACTION;');
|
|
||||||
await this.$parseBlock(block);
|
await this.$parseBlock(block);
|
||||||
await this.$saveLatestBlockToDatabase(block.height);
|
await this.$saveLatestBlockToDatabase(block.height);
|
||||||
await DB.query('COMMIT;');
|
|
||||||
}
|
}
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await DB.query('ROLLBACK;');
|
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
throw new Error(e instanceof Error ? e.message : 'Error');
|
throw new Error(e instanceof Error ? e.message : 'Error');
|
||||||
}
|
}
|
||||||
@ -189,9 +186,7 @@ class ElementsParser {
|
|||||||
// The slow way: parse the block to look for the spending tx
|
// The slow way: parse the block to look for the spending tx
|
||||||
const blockHash: IBitcoinApi.ChainTips = await bitcoinSecondClient.getBlockHash(auditProgress.lastBlockAudit);
|
const blockHash: IBitcoinApi.ChainTips = await bitcoinSecondClient.getBlockHash(auditProgress.lastBlockAudit);
|
||||||
const block: IBitcoinApi.Block = await bitcoinSecondClient.getBlock(blockHash, 2);
|
const block: IBitcoinApi.Block = await bitcoinSecondClient.getBlock(blockHash, 2);
|
||||||
await DB.query('START TRANSACTION;');
|
|
||||||
await this.$parseBitcoinBlock(block, spentAsTip, unspentAsTip, auditProgress.confirmedTip, redeemAddresses);
|
await this.$parseBitcoinBlock(block, spentAsTip, unspentAsTip, auditProgress.confirmedTip, redeemAddresses);
|
||||||
await DB.query(`COMMIT;`);
|
|
||||||
|
|
||||||
// Finally, update the lastblockupdate of the remaining UTXOs and save to the database
|
// Finally, update the lastblockupdate of the remaining UTXOs and save to the database
|
||||||
const [minBlockUpdate] = await DB.query(`SELECT MIN(lastblockupdate) AS lastblockupdate FROM federation_txos WHERE unspent = 1`)
|
const [minBlockUpdate] = await DB.query(`SELECT MIN(lastblockupdate) AS lastblockupdate FROM federation_txos WHERE unspent = 1`)
|
||||||
@ -204,7 +199,6 @@ class ElementsParser {
|
|||||||
|
|
||||||
this.isUtxosUpdatingRunning = false;
|
this.isUtxosUpdatingRunning = false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await DB.query('ROLLBACK;');
|
|
||||||
this.isUtxosUpdatingRunning = false;
|
this.isUtxosUpdatingRunning = false;
|
||||||
throw new Error(e instanceof Error ? e.message : 'Error');
|
throw new Error(e instanceof Error ? e.message : 'Error');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user