mirror of
https://github.com/mempool/mempool.git
synced 2025-02-24 06:47:52 +01:00
Wrap statistics db ops with try/catch
This commit is contained in:
parent
230f563235
commit
a805c86697
1 changed files with 64 additions and 56 deletions
|
@ -53,6 +53,7 @@ class Statistics {
|
|||
memPoolArray = memPoolArray.filter((tx) => tx.effectiveFeePerVsize);
|
||||
|
||||
if (!memPoolArray.length) {
|
||||
try {
|
||||
const insertIdZeroed = await this.$createZeroedStatistic();
|
||||
if (this.newStatisticsEntryCallback && insertIdZeroed) {
|
||||
const newStats = await this.$get(insertIdZeroed);
|
||||
|
@ -60,6 +61,9 @@ class Statistics {
|
|||
this.newStatisticsEntryCallback(newStats);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.err('Unable to insert zeroed statistics. ' + e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -90,6 +94,7 @@ class Statistics {
|
|||
}
|
||||
});
|
||||
|
||||
try {
|
||||
const insertId = await this.$create({
|
||||
added: 'NOW()',
|
||||
unconfirmed_transactions: memPoolArray.length,
|
||||
|
@ -144,6 +149,9 @@ class Statistics {
|
|||
this.newStatisticsEntryCallback(newStats);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.err('Unable to insert statistics. ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
private async $createZeroedStatistic(): Promise<number | undefined> {
|
||||
|
|
Loading…
Add table
Reference in a new issue