From 50c22ca30047586b7ac944b6c9e80cb623ef8de9 Mon Sep 17 00:00:00 2001 From: Guillaume Le Vaillant Date: Wed, 8 Jul 2020 11:13:33 +0200 Subject: [PATCH] Mining: Indicate probability of finding a block in one day --- pages/Mining.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pages/Mining.qml b/pages/Mining.qml index b1756e82..edee35c7 100644 --- a/pages/Mining.qml +++ b/pages/Mining.qml @@ -251,7 +251,19 @@ Rectangle { function updateStatusText() { if (appWindow.isMining) { - statusText.text = qsTr("Mining at %1 H/s").arg(walletManager.miningHashRate()) + translationManager.emptyString; + var userHashRate = walletManager.miningHashRate(); + if (userHashRate === 0) { + statusText.text = qsTr("Mining temporarily suspended.") + translationManager.emptyString; + } + else { + var blockTime = 120; + var blocksPerDay = 86400 / blockTime; + var globalHashRate = walletManager.networkDifficulty() / blockTime; + var probabilityFindNextBlock = userHashRate / globalHashRate; + var probabilityFindBlockDay = 1 - Math.pow(1 - probabilityFindNextBlock, blocksPerDay); + var chanceFindBlockDay = Math.round(1 / probabilityFindBlockDay); + statusText.text = qsTr("Mining at %1 H/s. It gives you a 1 in %2 daily chance of finding a block.").arg(userHashRate).arg(chanceFindBlockDay) + translationManager.emptyString; + } } else { statusText.text = qsTr("Not mining") + translationManager.emptyString;