dynamic load state sync block

This commit is contained in:
liangping 2023-11-28 10:14:26 +08:00
parent ca59e3d586
commit 7b8c2463d1

View File

@ -10,15 +10,20 @@ const blockchain = useBlockchain();
const base = useBaseStore(); const base = useBaseStore();
const nodeInfo = ref({} as NodeInfo); const nodeInfo = ref({} as NodeInfo);
const height = ref(Number(base.latest.block?.header?.height|| 2001)) const height = ref(0)
const hash = ref("") const hash = ref("")
if(height.value > 2000) { base.$subscribe((m, { latest }) => {
height.value = Math.round((height.value - 2000) / 1000) * 1000 let h = Number(latest.block?.header?.height)
base.fetchBlock(height.value).then(res => { h = Math.round((h - 2000) / 1000) * 1000
hash.value = toHex(fromBase64(res.block_id.hash)).toUpperCase() if (h > height.value) {
}) height.value = h
} base.fetchBlock(h).then(res => {
hash.value = toHex(fromBase64(res.block_id.hash)).toUpperCase()
})
}
})
const rpcs = computed(() => { const rpcs = computed(() => {
return blockchain.current?.endpoints?.rpc return blockchain.current?.endpoints?.rpc
?.map((x) => x.address) ?.map((x) => x.address)
@ -41,14 +46,10 @@ onMounted(() => {
<h2 class="card-title truncate mb-2">{{ $t('statesync.title') }}</h2> <h2 class="card-title truncate mb-2">{{ $t('statesync.title') }}</h2>
<div class="text-sm"> <div class="text-sm">
{{ $t('statesync.description') }} {{ $t('statesync.description') }}
<a <a class="text-primary lowercase" href="https://blog.cosmos.network/cosmos-sdk-state-sync-guide-99e4cf43be2f">{{
class="text-primary lowercase" $t('statesync.here') }}&nbsp;</a>
href="https://blog.cosmos.network/cosmos-sdk-state-sync-guide-99e4cf43be2f" <a class="lowercase">
>{{ $t('statesync.here') }}&nbsp;</a {{ $t('statesync.for_more_info') }}.</a>
>
<a
class="lowercase">
{{ $t('statesync.for_more_info') }}.</a>
</div> </div>
</div> </div>
@ -67,22 +68,24 @@ onMounted(() => {
{{ $t('statesync.text_2_1') }}. {{ $t('statesync.text_2_1') }}.
<br /><br /> <br /><br />
<div class="mockup-code bg-base-200 my-2"> <div class="mockup-code bg-base-200 my-2">
<pre data-prefix=">"><code class="text-gray-800 dark:invert">[state-sync]</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">[state-sync]</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">enable = true</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">enable = true</code></pre>
<pre data-prefix=">"><code class="text-gray-800"></code></pre> <pre data-prefix=">"><code class="text-gray-800"></code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">rpc_servers = "{{ rpcs }}"</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">rpc_servers = "{{ rpcs }}"</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">trust_height = {{ height }} </code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">trust_height = {{ height }} </code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">trust_hash = "{{hash}}"</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">trust_hash = "{{ hash }}"</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert"></code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert"></code></pre>
<pre data-prefix=">"><code class="text-green-400"># 2/3 of unbonding time</code></pre> <pre data-prefix=">"><code class="text-green-400"># 2/3 of unbonding time</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">trust_period = "168h"</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">trust_period = "168h"</code></pre>
</div> </div>
<br /> <br />
3. {{ $t('statesync.text_3') }}: <code class="bg-base-200 text-gray-600 px-2 py-px mx-1 rounded shadow">{{ appName }} start</code> 3. {{ $t('statesync.text_3') }}: <code
class="bg-base-200 text-gray-600 px-2 py-px mx-1 rounded shadow">{{ appName }} start</code>
<br /> <br />
{{ $t('statesync.text_3_1') }} {{ $t('statesync.text_3_1') }}
<code class="bg-base-200 text-gray-600 px-2 py-px mx-1 rounded shadow">{{ appName }} unsafe-reset-all</code> or <code class="bg-base-200 text-gray-600 px-2 py-px mx-1 rounded shadow">{{ appName }} unsafe-reset-all</code> or
<code class="bg-base-200 text-gray-600 px-2 py-px mx-1 rounded shadow">{{ appName }} tendermint unsafe-reset-all --home ~/.HOME</code> <code
class="bg-base-200 text-gray-600 px-2 py-px mx-1 rounded shadow">{{ appName }} tendermint unsafe-reset-all --home ~/.HOME</code>
{{ $t('statesync.text_3_2') }}. {{ $t('statesync.text_3_2') }}.
</div> </div>
</div> </div>
@ -93,13 +96,16 @@ onMounted(() => {
{{ $t('statesync.text_title_3') }} {{ $t('statesync.text_title_3') }}
<br /><br /> <br /><br />
<div class="mockup-code bg-base-200 my-2"> <div class="mockup-code bg-base-200 my-2">
<pre data-prefix=">"><code class="text-gray-800 dark:invert">[state-sync]</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">[state-sync]</code></pre>
<pre data-prefix=">"><code class="text-green-400"># snapshot-interval specifies the block interval at which local state sync snapshots are</code></pre> <pre
<pre data-prefix=">"><code class="text-green-400"># taken (0 to disable). Must be a multiple of pruning-keep-every.</code></pre> data-prefix=">"><code class="text-green-400"># snapshot-interval specifies the block interval at which local state sync snapshots are</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">snapshot-interval = 1000</code></pre> <pre
<pre data-prefix=">"><code class="text-gray-800 dark:invert"></code></pre> data-prefix=">"><code class="text-green-400"># taken (0 to disable). Must be a multiple of pruning-keep-every.</code></pre>
<pre data-prefix=">"><code class="text-green-400"># snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). Each snapshot is about 500MiB</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert">snapshot-interval = 1000</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">snapshot-keep-recent = 2</code></pre> <pre data-prefix=">"><code class="text-gray-800 dark:invert"></code></pre>
<pre
data-prefix=">"><code class="text-green-400"># snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). Each snapshot is about 500MiB</code></pre>
<pre data-prefix=">"><code class="text-gray-800 dark:invert">snapshot-keep-recent = 2</code></pre>
</div> </div>
</div> </div>
</div> </div>