From 01f3e59adcd332b1d0c5946497b50c31477d03a6 Mon Sep 17 00:00:00 2001 From: sisou Date: Sat, 28 Apr 2018 11:11:44 -0600 Subject: [PATCH] Add helper function to get total blocks mined --- src/Helper.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Helper.js b/src/Helper.js index 5e25d29..d4130dc 100644 --- a/src/Helper.js +++ b/src/Helper.js @@ -90,6 +90,19 @@ class Helper { return -1; } } + + /** + * @returns {Promise.} + */ + 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;