Fix first diff adjustmeent if INDEXING_BLOCK_AMOUNT is not -1

This commit is contained in:
nymkappa
2022-07-09 13:14:09 +02:00
committed by softsimon
parent f4667c0892
commit cdf0fe0335
2 changed files with 25 additions and 17 deletions

View File

@@ -612,17 +612,17 @@ class BlocksRepository {
}
/**
* Return the oldest block timestamp from a consecutive chain of block from the most recent one
* Return the oldest block from a consecutive chain of block from the most recent one
*/
public async $getOldestConsecutiveBlockTimestamp(): Promise<number> {
public async $getOldestConsecutiveBlock(): Promise<any> {
try {
const [rows]: any = await DB.query(`SELECT height, UNIX_TIMESTAMP(blockTimestamp) as timestamp FROM blocks ORDER BY height DESC`);
const [rows]: any = await DB.query(`SELECT height, UNIX_TIMESTAMP(blockTimestamp) as timestamp, difficulty FROM blocks ORDER BY height DESC`);
for (let i = 0; i < rows.length - 1; ++i) {
if (rows[i].height - rows[i + 1].height > 1) {
return rows[i].timestamp;
return rows[i];
}
}
return rows[rows.length - 1].timestamp;
return rows[rows.length - 1];
} catch (e) {
logger.err('Cannot generate block size and weight history. Reason: ' + (e instanceof Error ? e.message : e));
throw e;