From 1c44a04cd47ce1147fc80164a8847711508ea70a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 16 May 2023 22:42:05 +0800 Subject: [PATCH] fix error --- src/modules/[chain]/indexStore.ts | 21 ++++++---- src/modules/[chain]/statesync/index.vue | 16 +++++--- src/modules/[chain]/uptime/index.vue | 52 ++++++++++++------------- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/modules/[chain]/indexStore.ts b/src/modules/[chain]/indexStore.ts index 771976df..3ffc64d0 100644 --- a/src/modules/[chain]/indexStore.ts +++ b/src/modules/[chain]/indexStore.ts @@ -87,29 +87,35 @@ export const useIndexModule = defineStore('module-index', { return useBankStore(); }, twitter(): string { - return `https://twitter.com/${this.coinInfo.links.twitter_screen_name}`; + if(!this.coinInfo?.links?.twitter_screen_name) return "" + return `https://twitter.com/${this.coinInfo?.links.twitter_screen_name}`; }, homepage(): string { - const [page1, page2, page3] = this.coinInfo.links?.homepage; + if(!this.coinInfo?.links?.homepage) return "" + const [page1, page2, page3] = this.coinInfo?.links?.homepage; return page1 || page2 || page3; }, github(): string { - const [page1, page2, page3] = this.coinInfo.links?.repos_url?.github; + if(!this.coinInfo?.links?.repos_url) return "" + const [page1, page2, page3] = this.coinInfo?.links?.repos_url?.github; return page1 || page2 || page3; }, telegram(): string { - return `https://t.me/${this.coinInfo.links.telegram_channel_identifier}`; + if(!this.coinInfo?.links?.homepage) return "" + return `https://t.me/${this.coinInfo?.links.telegram_channel_identifier}`; }, priceChange(): string { + if(!this.coinInfo?.market_data?.price_change_percentage_24h) return "" const change = - this.coinInfo.market_data?.price_change_percentage_24h || 0; + this.coinInfo?.market_data?.price_change_percentage_24h || 0; return numeral(change).format('+0.[00]'); }, priceColor(): string { + if(!this.coinInfo?.market_data?.price_change_percentage_24h) return "" const change = - this.coinInfo.market_data?.price_change_percentage_24h || 0; + this.coinInfo?.market_data?.price_change_percentage_24h || 0; switch (true) { case change > 0: return 'text-success'; @@ -120,7 +126,8 @@ export const useIndexModule = defineStore('module-index', { } }, trustColor(): string { - const change = this.coinInfo.tickers[this.tickerIndex]?.trust_score; + if(!this.coinInfo?.tickers) return "" + const change = this.coinInfo?.tickers[this.tickerIndex]?.trust_score; return colorMap(change); }, diff --git a/src/modules/[chain]/statesync/index.vue b/src/modules/[chain]/statesync/index.vue index 178b9a52..df75088b 100644 --- a/src/modules/[chain]/statesync/index.vue +++ b/src/modules/[chain]/statesync/index.vue @@ -10,6 +10,15 @@ const blockchain = useBlockchain(); const base = useBaseStore(); const nodeInfo = ref({} as NodeInfo); +const height = ref(Number(base.latest.block?.header?.height|| 2001)) +const hash = ref(toHex(fromBase64(base.latest.block_id.hash))) + +if(height.value > 2000) { + height.value = Math.round((height.value - 2000) / 1000) * 1000 + base.fetchBlock(height.value).then(res => { + hash.value = toHex(fromBase64(res.block_id.hash)).toUpperCase() + }) +} const state = computed(() => { const rpcs = blockchain.current?.endpoints?.rpc ?.map((x) => x.address) @@ -17,10 +26,8 @@ const state = computed(() => { return `[statesync] enable = true rpc_servers = "${rpcs}" -trust_height = ${base.latest.block?.header?.height || 'loading'} -trust_hash = "${ - base.latest.block_id ? toHex(fromBase64(base.latest.block_id?.hash)) : '' - }" +trust_height = ${height.value || 'loading'} +trust_hash = "${hash.value}" trust_period = "168h" # 2/3 of unbonding time" `; }); @@ -31,7 +38,6 @@ const appName = computed(() => { onMounted(() => { blockchain.rpc.getBaseNodeInfo().then((x) => { - console.log('node info', x); nodeInfo.value = x; }); }); diff --git a/src/modules/[chain]/uptime/index.vue b/src/modules/[chain]/uptime/index.vue index 4ab0bb66..f52d5869 100644 --- a/src/modules/[chain]/uptime/index.vue +++ b/src/modules/[chain]/uptime/index.vue @@ -49,24 +49,22 @@ onMounted(() => { latest.value = Number(b.block.header.height); commits.value.unshift(b.block.last_commit); const height = Number(b.block.header?.height || 0); - if (height === 0) { + if (height > 50) { // constructs sequence for loading blocks let promise = Promise.resolve(); for (let i = height - 1; i > height - 50; i -= 1) { - if (i > height - 48) { - promise = promise.then( - () => - new Promise((resolve, reject) => { - if (live.value && commits2.value.length < 50) { - // continue only if the page is living - baseStore.fetchBlock(i).then((x) => { - commits.value.unshift(x.block.last_commit); - resolve(); - }); - } - }) - ); - } + promise = promise.then( + () => + new Promise((resolve, reject) => { + if (live.value && commits2.value.length < 50) { + // continue only if the page is living + baseStore.fetchBlock(i).then((x) => { + commits.value.unshift(x.block.last_commit); + resolve(); + }); + } + }) + ); } } }); @@ -143,28 +141,26 @@ function changeTab(v: string) {
| Validator | -Start Height | -Signed Blocks | -Missing blocks | -Last Jailed Time | -Tombstoned | -||
| In Window | -Over All | +Validator | +Start Height | +Signed Precommits | +Missing blocks | +Last Jailed Time | +Tombstoned |
| {{ i+1 }}. {{ v.description.moniker }} | {{ signing?.start_height }} | -{{ signing?.index_offset }} | ++ {{ signing?.index_offset }} + {{ format.percent(Number(signing.index_offset)/(latest-Number(signing.start_height))) }} + | {{ signing?.missed_blocks_counter }} | -{{ format.percent(Number(signing.index_offset)/(latest-Number(signing.start_height))) }} |
{{ format.toDay(signing?.jailed_until, "from") }}
| |