Skip to content

Commit

Permalink
selectpaste component added
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylcode authored Sep 9, 2023
1 parent a153504 commit a3d3366
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 22 deletions.
19 changes: 0 additions & 19 deletions docs/zetachain/sync/state sync.md

This file was deleted.

23 changes: 23 additions & 0 deletions docs/zetachain/sync/state-sync.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
sidebar_position: 2
description: State Sync
---

# State Sync

> State Sync allows new nodes to join a blockchain network by downloading a recent snapshot of the application state instead of processing all historical blocks. This approach is typically faster and requires less data, as the application state is usually more concise than the entire block history.
import SelectPaste from '@site/src/components/SelectPaste';

explore let rpc = [
'https://rpc1.node1111.test9999999.com',
'https://rpc2.node2222.test9999999.com',
'https://rpc3.node3333.test9999999.com',
'https://rpc4.node4444.test9999999.com',
'https://rpc5.node5555.test9999999.com',
'https://rpc6.node6666.test9999999.com',
'https://rpc7.node7777.test9999999.com',
'https://rpc8.node8888.test9999999.com',
];

<SelectPaste rpc={rpc} />
55 changes: 55 additions & 0 deletions src/components/SelectPaste/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useState } from "react";
import CodeBlock from "@theme/CodeBlock";
import Admonition from "@theme/Admonition";

interface SelectPasteProps {
rpc: string[];
}

const SelectPaste: React.FC<SelectPasteProps> = ({ rpc }) => {
const [selectedRpc, setSelectedRpc] = useState<string>(rpc[0]);

return (
<div>
<Admonition type="tip" icon="📘" title="How to Use">
<p>Click on any RPC to paste it into the code block.</p>
</Admonition>

<CodeBlock language="bash" showLineNumbers>
{`sudo systemctl stop zetacored
cp $HOME/.zetacored/data/priv_validator_state.json $HOME/.zetacored/priv_validator_state.json.backup
zetacored tendermint unsafe-reset-all --home $HOME/.zetacored --keep-addr-book
CUSTOM_RPC="${selectedRpc}"
LATEST_HEIGHT=$(curl -s $CUSTOM_RPC/block | jq -r .result.block.header.height)
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1500))
TRUST_HASH=$(curl -s "$CUSTOM_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH
sed -i 's|^enable *=.*|enable = true|' $HOME/.zetacored/config/config.toml
sed -i 's|^rpc_servers *=.*|rpc_servers = "'$CUSTOM_RPC,$CUSTOM_RPC'"|' $HOME/.zetacored/config/config.toml
sed -i 's|^trust_height *=.*|trust_height = '$BLOCK_HEIGHT'|' $HOME/.zetacored/config/config.toml
sed -i 's|^trust_hash *=.*|trust_hash = "'$TRUST_HASH'"|' $HOME/.zetacored/config/config.toml
mv $HOME/.zetacored/priv_validator_state.json.backup $HOME/.zetacored/data/priv_validator_state.json
sudo systemctl restart zetacored
sudo journalctl -u zetacored -f --no-hostname -o cat
`}
</CodeBlock>

<div className="button-group card">
{rpc.map((item, index) => (
<button className="button button--secondary" key={index} onClick={() => setSelectedRpc(item)}>
{item}
</button>
))}
</div>
</div>
);
};

export default SelectPaste;
Loading

0 comments on commit a3d3366

Please sign in to comment.