Mining stats does not depends on the websocket blocks number anymore

This commit is contained in:
nymkappa
2022-04-01 12:41:25 +09:00
parent 2374f98ca8
commit c3a3289fcf
3 changed files with 39 additions and 19 deletions

View File

@@ -386,10 +386,14 @@ class BlocksRepository {
connection = await DB.getConnection();
// We need to use a subquery
const query = `SELECT SUM(reward) as totalReward, SUM(fees) as totalFee, SUM(tx_count) as totalTx
FROM (SELECT reward, fees, tx_count FROM blocks ORDER by height DESC LIMIT ${blockCount}) as sub`;
const query = `
SELECT MIN(height) as startBlock, MAX(height) as endBlock, SUM(reward) as totalReward, SUM(fees) as totalFee, SUM(tx_count) as totalTx
FROM
(SELECT height, reward, fees, tx_count FROM blocks
ORDER by height DESC
LIMIT ?) as sub`;
const [rows]: any = await connection.query(query);
const [rows]: any = await connection.query(query, [blockCount]);
connection.release();
return rows[0];