Truncate hashrates after #1435 - Fix hashrate indexing logs

This commit is contained in:
nymkappa 2022-03-24 07:40:03 +09:00
parent 80a103acab
commit 185dddd8c7
No known key found for this signature in database
GPG Key ID: E155910B16E8BD04
2 changed files with 8 additions and 3 deletions

View File

@ -6,7 +6,7 @@ import logger from '../logger';
const sleep = (ms: number) => new Promise(res => setTimeout(res, ms));
class DatabaseMigration {
private static currentVersion = 15;
private static currentVersion = 16;
private queryTimeout = 120000;
private statisticsAddedIndexed = false;
@ -175,6 +175,11 @@ class DatabaseMigration {
await this.$executeQuery(connection, 'ALTER TABLE `hashrates` MODIFY `pool_id` SMALLINT UNSIGNED NOT NULL DEFAULT "0"');
}
if (databaseSchemaVersion < 16 && isBitcoin === true) {
logger.warn(`'hashrates' table has been truncated. Re-indexing from scratch.`);
await this.$executeQuery(connection, 'TRUNCATE hashrates;'); // Need to re-index because we changed timestamps
}
connection.release();
} catch (e) {
connection.release();

View File

@ -154,7 +154,7 @@ class Mining {
await HashratesRepository.$saveHashrates(hashrates);
hashrates.length = 0;
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime()) - startedAt));
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime()) - startedAt)) / 1000;
if (elapsedSeconds > 1) {
const weeksPerSeconds = (indexedThisRun / elapsedSeconds).toFixed(2);
const formattedDate = new Date(fromTimestamp).toUTCString();
@ -244,7 +244,7 @@ class Mining {
hashrates.length = 0;
}
const elapsedSeconds = Math.max(1, Math.round(new Date().getTime() - startedAt));
const elapsedSeconds = Math.max(1, Math.round(new Date().getTime() - startedAt)) / 1000;
if (elapsedSeconds > 1) {
const daysPerSeconds = (indexedThisRun / elapsedSeconds).toFixed(2);
const formattedDate = new Date(fromTimestamp).toUTCString();