Skip to content

Commit

Permalink
Add helper function to get total blocks mined
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed May 3, 2018
1 parent 3745f65 commit 01f3e59
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ class Helper {
return -1;
}
}

/**
* @returns {Promise.<number>}
*/
static async getTotalBlocksMined(connectionPool) {
const query = `
SELECT COUNT(DISTINCT payin.block) AS blockcount FROM payin
INNER JOIN block ON block.id = payin.block
WHERE block.main_chain = 1
`;
const [rows, fields] = await connectionPool.execute(query);
return rows[0].blockcount;
}
}

module.exports = exports = Helper;

0 comments on commit 01f3e59

Please sign in to comment.