mirror of
https://github.com/mempool/mempool.git
synced 2024-11-20 18:32:19 +01:00
Merge branch 'master' into bugfix/stop-block-chunk-indexing-upon-error
This commit is contained in:
commit
8b1a0fe706
@ -108,6 +108,8 @@ class Mining {
|
||||
if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.hashrateIndexingStarted = true;
|
||||
|
||||
logger.info(`Indexing hashrates`);
|
||||
@ -142,7 +144,7 @@ class Mining {
|
||||
lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
||||
blockStats.lastBlockHeight);
|
||||
|
||||
if (totalIndexed % 7 === 0 && !indexedTimestamp.includes(fromTimestamp + 1)) { // Save weekly pools hashrate
|
||||
if (totalIndexed > 7 && totalIndexed % 7 === 0 && !indexedTimestamp.includes(fromTimestamp + 1)) { // Save weekly pools hashrate
|
||||
logger.debug("Indexing weekly hashrates for mining pools");
|
||||
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp - 604800, fromTimestamp);
|
||||
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
|
||||
@ -208,6 +210,10 @@ class Mining {
|
||||
this.hashrateIndexingStarted = false;
|
||||
|
||||
logger.info(`Hashrates indexing completed`);
|
||||
} catch (e) {
|
||||
this.hashrateIndexingStarted = false;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ class Server {
|
||||
await Common.sleep(5000);
|
||||
await databaseMigration.$truncateIndexedData(tables);
|
||||
}
|
||||
await this.$resetHashratesIndexingState();
|
||||
await databaseMigration.$initializeOrMigrateDatabase();
|
||||
await this.$resetHashratesIndexingState();
|
||||
await poolsParser.migratePoolsJson();
|
||||
} catch (e) {
|
||||
throw new Error(e instanceof Error ? e.message : 'Error');
|
||||
|
@ -22,6 +22,7 @@ class HashratesRepository {
|
||||
await connection.query(query);
|
||||
} catch (e: any) {
|
||||
logger.err('$saveHashrateInDatabase() error' + (e instanceof Error ? e.message : e));
|
||||
throw e;
|
||||
}
|
||||
|
||||
connection.release();
|
||||
|
Loading…
Reference in New Issue
Block a user