Merge pull request #1182 from nymkappa/bugfix/statistics-db-error-handling
Wrap statistics db ops with try/catch
This commit is contained in:
commit
eb32b13acb
@ -53,6 +53,7 @@ class Statistics {
|
|||||||
memPoolArray = memPoolArray.filter((tx) => tx.effectiveFeePerVsize);
|
memPoolArray = memPoolArray.filter((tx) => tx.effectiveFeePerVsize);
|
||||||
|
|
||||||
if (!memPoolArray.length) {
|
if (!memPoolArray.length) {
|
||||||
|
try {
|
||||||
const insertIdZeroed = await this.$createZeroedStatistic();
|
const insertIdZeroed = await this.$createZeroedStatistic();
|
||||||
if (this.newStatisticsEntryCallback && insertIdZeroed) {
|
if (this.newStatisticsEntryCallback && insertIdZeroed) {
|
||||||
const newStats = await this.$get(insertIdZeroed);
|
const newStats = await this.$get(insertIdZeroed);
|
||||||
@ -60,6 +61,9 @@ class Statistics {
|
|||||||
this.newStatisticsEntryCallback(newStats);
|
this.newStatisticsEntryCallback(newStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.err('Unable to insert zeroed statistics. ' + e);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +94,7 @@ class Statistics {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
const insertId = await this.$create({
|
const insertId = await this.$create({
|
||||||
added: 'NOW()',
|
added: 'NOW()',
|
||||||
unconfirmed_transactions: memPoolArray.length,
|
unconfirmed_transactions: memPoolArray.length,
|
||||||
@ -144,6 +149,9 @@ class Statistics {
|
|||||||
this.newStatisticsEntryCallback(newStats);
|
this.newStatisticsEntryCallback(newStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.err('Unable to insert statistics. ' + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async $createZeroedStatistic(): Promise<number | undefined> {
|
private async $createZeroedStatistic(): Promise<number | undefined> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user