ResistancePlatform / grants

Resistance Platform Grant System
0 stars 0 forks source link

Sync percentage indicator #2

Open lukewegryn opened 4 years ago

lukewegryn commented 4 years ago

This is a proposal for bug fixes to the Resistance Desktop wallet:

Currently displays the wrong values when the block headers are read (correct afterwards). Also, the send button should be frozen before 100% is reached.

If this proposal is approved by the Masternode voters, then the developers that fix these bugs will be issued a grant from the developer's fund (from the 10% reward splitting).

The amount of RES granted will be: 47,500 RES

A simple majority will be used to approve or reject this proposal. At least one Masternode must vote on an issue for it to be approved. To apply with a proposal email admin [at] resistance.io and include your GitHub username in your email so our admins can verify your development record. For information on how to cast your vote, please refer to the README in this repository.

Voting opens immediately and will close on: Friday, June 26, 2020 at 23:59 UTC

lukewegryn commented 4 years ago

-----BEGIN VOTE----- Y:2:r16bGySCm5ycJFbqaH1eN4pKuEcaecXBRzA:1592926593:ICxeG79hY4hOCXdrM79WfwBhNr4LkQO4hAw/uzV9flSWILIFSer0bVrWsEOTT569JhoAoDaOPWdqhB813lKuUEg= -----END VOTE-----

whiteknightrader commented 4 years ago

-----BEGIN VOTE----- Y:2:r17bxNVqW8o2BmXy6CEZnkDDyXcTHFWyQbB:1592932760:H4YlG3WPEFqwtQL8WBCsYzliudwmGNEM+puPBNLQ22DkGfCx5Ambwl2n5gz0t/1+4gzD4VB8T0Jkqu8OxpZoTWI= -----END VOTE-----

MEtoolel commented 4 years ago

Y:2:r18fiaRwkHZNy2n37wRLrH4SuFTfJJCS2HV:1592983551:IH+n7q4SnVHW7fLvqFrnKAHOoDznAoT3yVH9O/HhPnWVZKb+PB13m04okFYRLpvMmThXI1pycvkE0RU8ggC8ZKk=

ghost commented 4 years ago

-----BEGIN VOTE----- Y:2:r13fwb1K9sK6YYoTf22c6CJPxequKMxcA7L:1592983699:H3hihdrzfjPNB0mGrr1/Enu39Ygs/ZUhTIWF6KvI3xskbkSkAT5nnEHE54wZhQcxiAbjZmMWaSF4L6Eit1Bf7+A= -----END VOTE-----

lukewegryn commented 4 years ago

The votes have been tallied and the results are in favor of accepting this proposal.

cat list_of_votes2.txt
-----BEGIN VOTE-----
Y:2:r16bGySCm5ycJFbqaH1eN4pKuEcaecXBRzA:1592926593:ICxeG79hY4hOCXdrM79WfwBhNr4LkQO4hAw/uzV9flSWILIFSer0bVrWsEOTT569JhoAoDaOPWdqhB813lKuUEg=
-----END VOTE-----
-----BEGIN VOTE-----
Y:2:r17bxNVqW8o2BmXy6CEZnkDDyXcTHFWyQbB:1592932760:H4YlG3WPEFqwtQL8WBCsYzliudwmGNEM+puPBNLQ22DkGfCx5Ambwl2n5gz0t/1+4gzD4VB8T0Jkqu8OxpZoTWI=
-----END VOTE-----
-----BEGIN VOTE-----
Y:2:r18fiaRwkHZNy2n37wRLrH4SuFTfJJCS2HV:1592983551:IH+n7q4SnVHW7fLvqFrnKAHOoDznAoT3yVH9O/HhPnWVZKb+PB13m04okFYRLpvMmThXI1pycvkE0RU8ggC8ZKk=
-----END VOTE-----
-----BEGIN VOTE-----
Y:2:r13fwb1K9sK6YYoTf22c6CJPxequKMxcA7L:1592983699:H3hihdrzfjPNB0mGrr1/Enu39Ygs/ZUhTIWF6KvI3xskbkSkAT5nnEHE54wZhQcxiAbjZmMWaSF4L6Eit1Bf7+A=
-----END VOTE-----
cat list_of_votes2.txt | grep -v "BEGIN VOTE" | grep -v "END VOTE" | ./verify.sh 2
jq installed... proceeding
curl installed... proceeding

--------------------------------------------------------
| Final Tally for GitHub Issue: 2
--------------------------------------------------------
| YES: 4
|-------------------------------------------------------
| NO: 0
--------------------------------------------------------

This grant is approved. Once the terms of the proposal are met, we will release the RES reward from the dev fund.

whiteknightrader commented 4 years ago

Hi, I will try to resolve this.

whiteknightrader commented 3 years ago

diff --git a/app/service/rpc-service.js b/app/service/rpc-service.js
index 50c8b43..650ac74 100644
--- a/app/service/rpc-service.js
+++ b/app/service/rpc-service.js

@@ -279,8 +279,11 @@ export class RpcService {
   requestBlockchainInfo() {
     const client = getClientInstance()

+    const timenow = () => new Date().getTime()
+    let lastBlocktime
+

@@ -288,21 +291,49 @@ export class RpcService {
     client.getConnectionCount()
       .then(result => {
         blockchainInfo.connectionCount = result
         return client.getBlockCount()
       })
       .then(result => client.getBlockHash(result))
       .then(result => client.getBlock(result))
       .then(result => {
         blockchainInfo.lastBlockDate = new Date(result.time * 1000)
+        lastBlocktime = Date.parse(blockchainInfo.lastBlockDate) / 1000
         return client.getBlockchainInfo()
       })
       .then(result => {
         blockchainInfo.synchronizedPercentage = 0

-        if (result.headers > 0) {
-          blockchainInfo.synchronizedPercentage = 100.0 * result.blocks / result.headers
+        let blockDiff = (timenow() / 1000 - lastBlocktime) / 60
+        // Design constraint, no way to check if system time is in the future
+        if (blockDiff < -150) {
+          throw new Error("Incorrect System Time")
+        }
+        if (blockDiff < 0) {
+          blockDiff = 0
         }

+        let estimatedTotalHeight = result.blocks + blockDiff
+        if (estimatedTotalHeight < result.headers) {
+          estimatedTotalHeight = result.headers
+        }
+        if (estimatedTotalHeight < 500000) {
+          estimatedTotalHeight = 500000
+        }
+        let syncpercentonEstHeight =
+          (100.0 * [(result.blocks + result.headers) / 2]) /
+          (estimatedTotalHeight + 1)
+
+        // Resdex login works only on 100%
+        if (
+          estimatedTotalHeight - result.blocks < 60 &&
+          result.blocks === result.headers &&
+          result.blocks > 500000
+        ) {
+          syncpercentonEstHeight = 100
+        }
+
+        blockchainInfo.synchronizedPercentage = syncpercentonEstHeight
+
         getStore().dispatch(SystemInfoActions.gotBlockchainInfo(blockchainInfo))
         return Promise.resolve()
       })
whiteknightrader commented 3 years ago

As these changes are reviewed and merged into the code, kindly include the changes in next release for fixing the sync % issue.