Merge branch 'master' into simon/address-prefix-bug
This commit is contained in:
commit
552c717693
@ -218,7 +218,6 @@ class Blocks {
|
|||||||
if (blockHeight < lastBlockToIndex) {
|
if (blockHeight < lastBlockToIndex) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
++indexedThisRun;
|
++indexedThisRun;
|
||||||
if (++totaIndexed % 100 === 0 || blockHeight === lastBlockToIndex) {
|
if (++totaIndexed % 100 === 0 || blockHeight === lastBlockToIndex) {
|
||||||
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt));
|
const elapsedSeconds = Math.max(1, Math.round((new Date().getTime() / 1000) - startedAt));
|
||||||
@ -232,17 +231,15 @@ class Blocks {
|
|||||||
const transactions = await this.$getTransactionsExtended(blockHash, block.height, true, true);
|
const transactions = await this.$getTransactionsExtended(blockHash, block.height, true, true);
|
||||||
const blockExtended = await this.$getBlockExtended(block, transactions);
|
const blockExtended = await this.$getBlockExtended(block, transactions);
|
||||||
await blocksRepository.$saveBlockInDatabase(blockExtended);
|
await blocksRepository.$saveBlockInDatabase(blockExtended);
|
||||||
} catch (e) {
|
|
||||||
logger.err(`Something went wrong while indexing blocks.` + e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentBlockHeight -= chunkSize;
|
currentBlockHeight -= chunkSize;
|
||||||
}
|
}
|
||||||
logger.info('Block indexing completed');
|
logger.info('Block indexing completed');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('An error occured in $generateBlockDatabase(). Skipping block indexing. ' + e);
|
logger.err('An error occured in $generateBlockDatabase(). Trying again later. ' + e);
|
||||||
console.log(e);
|
this.blockIndexingStarted = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.blockIndexingCompleted = true;
|
this.blockIndexingCompleted = true;
|
||||||
|
@ -108,6 +108,8 @@ class Mining {
|
|||||||
if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) {
|
if (!blocks.blockIndexingCompleted || this.hashrateIndexingStarted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
this.hashrateIndexingStarted = true;
|
this.hashrateIndexingStarted = true;
|
||||||
|
|
||||||
logger.info(`Indexing hashrates`);
|
logger.info(`Indexing hashrates`);
|
||||||
@ -142,7 +144,7 @@ class Mining {
|
|||||||
lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
lastBlockHashrate = await bitcoinClient.getNetworkHashPs(blockStats.blockCount,
|
||||||
blockStats.lastBlockHeight);
|
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");
|
logger.debug("Indexing weekly hashrates for mining pools");
|
||||||
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp - 604800, fromTimestamp);
|
let pools = await PoolsRepository.$getPoolsInfoBetween(fromTimestamp - 604800, fromTimestamp);
|
||||||
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
|
const totalBlocks = pools.reduce((acc, pool) => acc + pool.blockCount, 0);
|
||||||
@ -208,6 +210,10 @@ class Mining {
|
|||||||
this.hashrateIndexingStarted = false;
|
this.hashrateIndexingStarted = false;
|
||||||
|
|
||||||
logger.info(`Hashrates indexing completed`);
|
logger.info(`Hashrates indexing completed`);
|
||||||
|
} catch (e) {
|
||||||
|
this.hashrateIndexingStarted = false;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ class Server {
|
|||||||
await Common.sleep(5000);
|
await Common.sleep(5000);
|
||||||
await databaseMigration.$truncateIndexedData(tables);
|
await databaseMigration.$truncateIndexedData(tables);
|
||||||
}
|
}
|
||||||
await this.$resetHashratesIndexingState();
|
|
||||||
await databaseMigration.$initializeOrMigrateDatabase();
|
await databaseMigration.$initializeOrMigrateDatabase();
|
||||||
|
await this.$resetHashratesIndexingState();
|
||||||
await poolsParser.migratePoolsJson();
|
await poolsParser.migratePoolsJson();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(e instanceof Error ? e.message : 'Error');
|
throw new Error(e instanceof Error ? e.message : 'Error');
|
||||||
|
@ -22,6 +22,7 @@ class HashratesRepository {
|
|||||||
await connection.query(query);
|
await connection.query(query);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.err('$saveHashrateInDatabase() error' + (e instanceof Error ? e.message : e));
|
logger.err('$saveHashrateInDatabase() error' + (e instanceof Error ? e.message : e));
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.release();
|
connection.release();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user