Set connection pool timezone to UTC - Close mysql connections upon error

This commit is contained in:
nymkappa
2022-03-06 16:44:09 +01:00
parent 91219bff92
commit 085f5e5cca
6 changed files with 196 additions and 93 deletions

View File

@@ -134,7 +134,8 @@ class DatabaseMigration {
}
if (databaseSchemaVersion < 9) {
await this.$executeQuery(connection, 'ALTER TABLE `state` CHANGE `name` `name` varchar(100)')
await this.$executeQuery(connection, 'ALTER TABLE `state` CHANGE `name` `name` varchar(100)');
await this.$executeQuery(connection, 'ALTER TABLE `hashrates` ADD UNIQUE `hashrate_timestamp_pool_id` (`hashrate_timestamp`, `pool_id`)');
}
connection.release();

View File

@@ -97,9 +97,8 @@ class Mining {
const indexedTimestamp = await HashratesRepository.$getWeeklyHashrateTimestamps();
const hashrates: any[] = [];
const genesisTimestamp = 1231006505; // bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
const lastWeekMidnight = this.getDateMidnight(new Date());
lastWeekMidnight.setDate(lastWeekMidnight.getDate() - 7);
let toTimestamp = Math.round(lastWeekMidnight.getTime() / 1000);
const lastMidnight = this.getDateMidnight(new Date());
let toTimestamp = Math.round((lastMidnight.getTime() - 604800) / 1000);
const totalWeekIndexed = (await BlocksRepository.$blockCount(null, null)) / 1008;
let indexedThisRun = 0;
@@ -167,7 +166,6 @@ class Mining {
this.weeklyHashrateIndexingStarted = false;
throw e;
}
}
/**