From 82eeaff60102c068aadfad3ca68308fd8c3cf426 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 18 Mar 2022 14:58:56 +0800 Subject: [PATCH] add missing blocks and filter by parameters --- src/libs/fetch.js | 8 ++--- src/views/Uptime.vue | 35 +++++++++++++++---- src/views/UptimeMyChainBlocks.vue | 37 +++++++++++++++----- src/views/UptimeMyValidators.vue | 56 ++++++++++++++++++++++++------- 4 files changed, 105 insertions(+), 31 deletions(-) diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 450c370d..3d473ae3 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -71,8 +71,8 @@ export default class ChainFetch { return this.get(`/blocks/${height}`, config).then(data => Block.create(data)) } - async getSlashingSigningInfo() { - return this.get('/cosmos/slashing/v1beta1/signing_infos') + async getSlashingSigningInfo(config = null) { + return this.get('/cosmos/slashing/v1beta1/signing_infos?pagination.limit=500', config) } async getTxs(hash) { @@ -140,8 +140,8 @@ export default class ChainFetch { }) } - async getValidatorList() { - return this.get('/staking/validators').then(data => { + async getValidatorList(config = null) { + return this.get('/staking/validators', config).then(data => { const vals = commonProcess(data).map(i => new Validator().init(i)) localStorage.setItem(`validators-${this.config.chain_name}`, JSON.stringify(vals)) return vals diff --git a/src/views/Uptime.vue b/src/views/Uptime.vue index 288e7f37..fc8b1d48 100644 --- a/src/views/Uptime.vue +++ b/src/views/Uptime.vue @@ -32,13 +32,23 @@ md="4" class="text-truncate" > - {{ index+1 }} {{ x.validator.moniker }} - +
+ {{ index+1 }} {{ x.validator.moniker }} + + + {{ missing[x.address].missed_blocks_counter }} + +
{ this.validators = res }) + this.$http.getSlashingSigningInfo().then(res => { + if (res.info) { + res.info.forEach(x => { + if (x.address) { + const hex = toHex(Bech32.decode(x.address).data).toUpperCase() + this.missing[hex] = x + } + }) + } + }) this.initBlocks() }, beforeDestroy() { diff --git a/src/views/UptimeMyChainBlocks.vue b/src/views/UptimeMyChainBlocks.vue index 8d9ff33b..ab0c3d64 100644 --- a/src/views/UptimeMyChainBlocks.vue +++ b/src/views/UptimeMyChainBlocks.vue @@ -23,14 +23,24 @@ sm="12" class="text-truncate" > - - {{ x.validator.moniker }} - +
+ + {{ x.validator.moniker }} + + + {{ missing[x.address].missed_blocks_counter }} + +
{ + if (res.info) { + res.info.forEach(x => { + if (x.address) { + const hex = toHex(Bech32.decode(x.address).data).toUpperCase() + this.missing[hex] = x + } + }) + } + }) }, beforeDestroy() { this.blocks = [] // clear running tasks if it is not finish diff --git a/src/views/UptimeMyValidators.vue b/src/views/UptimeMyValidators.vue index ddab0d7b..348eedf8 100644 --- a/src/views/UptimeMyValidators.vue +++ b/src/views/UptimeMyValidators.vue @@ -1,6 +1,6 @@