Skip to content

Commit

Permalink
Merge pull request #224 from MickWang/master
Browse files Browse the repository at this point in the history
fix block countdown issue
  • Loading branch information
MickWang authored Feb 25, 2020
2 parents 741aece + 9bd706f commit 9e0b9d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "owallet",
"productName": "OWallet",
"homepage": "http://ont.io",
"version": "v0.9.20",
"version": "v0.9.21",
"author": "Ontology Foundation Ltd. <[email protected]>",
"description": "OWallet is a comprehensive Ontology desktop wallet",
"license": "Apache-2.0",
Expand Down
24 changes: 13 additions & 11 deletions src/renderer/store/modules/NodeAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9e0b9d1

Please sign in to comment.