Create indexing sticky notification that show indexing progress in all mining dashboard related pages

This commit is contained in:
nymkappa
2022-05-02 17:28:58 +09:00
parent 11cdbb3118
commit 802e10e0a9
19 changed files with 95 additions and 20 deletions

View File

@@ -188,6 +188,24 @@ class BlocksRepository {
}
}
/**
* Get blocks count for a period
*/
public async $blockCountBetweenHeight(startHeight: number, endHeight: number): Promise<number> {
const params: any[] = [];
let query = `SELECT count(height) as blockCount
FROM blocks
WHERE height <= ${startHeight} AND height >= ${endHeight}`;
try {
const [rows] = await DB.query(query, params);
return <number>rows[0].blockCount;
} catch (e) {
logger.err(`Cannot count blocks for this pool (using offset). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/**
* Get the oldest indexed block
*/