From 9bd706f5df74ffd0c2100f6a27556d108aca5407 Mon Sep 17 00:00:00 2001 From: MickeyWang <1244134672@qq.com> Date: Mon, 24 Feb 2020 14:10:05 +0800 Subject: [PATCH] fix block countdown issue --- package.json | 2 +- .../store/modules/NodeAuthorization.js | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 7ecdd44..94655fa 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "owallet", "productName": "OWallet", "homepage": "http://ont.io", - "version": "v0.9.20", + "version": "v0.9.21", "author": "Ontology Foundation Ltd. ", "description": "OWallet is a comprehensive Ontology desktop wallet", "license": "Apache-2.0", diff --git a/src/renderer/store/modules/NodeAuthorization.js b/src/renderer/store/modules/NodeAuthorization.js index 85b3be7..99d4b0e 100644 --- a/src/renderer/store/modules/NodeAuthorization.js +++ b/src/renderer/store/modules/NodeAuthorization.js @@ -52,11 +52,12 @@ async function matchNodeName(list) { async function fetchRoundBlocks() { const net = localStorage.getItem('net'); - let url = net === 'TEST_NET' ? 'http://52.221.214.196:8090/v2/nodes/max-staking-change-count' - : 'http://18.136.216.3:8090/v2/nodes/max-staking-change-count' + let url = net === 'TEST_NET' ? 'https://polarisexplorer.ont.io/v2/nodes/block-count-to-next-round' + : 'https://explorer.ont.io/v2/nodes/block-count-to-next-round' const res = await axios.get(url); if (res.data && res.data.result) { - return Number(res.data.result); + const {max_staking_change_count, count_to_next_round} = res.data.result + return Number(count_to_next_round); } else { throw new Error('Network error when fetch block counts.') } @@ -439,14 +440,15 @@ const actions = { const url = getNodeUrl(); const rest = new RestClient(url); try { - const view = await GovernanceTxBuilder.getGovernanceView(url); - const blockRes = await rest.getBlockHeight(); - const blockHeight = blockRes.Result; - const blockCounts = await fetchRoundBlocks() - const countdown = blockCounts - (blockHeight - view.height); - if (countdown < 0) { - throw new Error('Network error for fetch block countdown.') - } + // const view = await GovernanceTxBuilder.getGovernanceView(url); + // const blockRes = await rest.getBlockHeight(); + // const blockHeight = blockRes.Result; + // const blockCounts = await fetchRoundBlocks() + // const countdown = blockCounts - (blockHeight - view.height); + // if (countdown < 0) { + // throw new Error('Network error for fetch block countdown.') + // } + const countdown = await fetchRoundBlocks() commit('UPDATE_COUNTDOWN_BLOCK', {countdown}) return countdown; }catch(err) {