Skip to content

Commit

Permalink
peers loading added
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylcode authored Sep 6, 2023
1 parent e1cd64c commit 1edc67b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 1 addition & 2 deletions docs/zetachain/sync/peers-seeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ description: Live Peers / Seeds

> When you start a node, you often need to connect to the network. This requires you to connect to one or more peers to start downloading the blockchain and receiving new blocks and transactions. Seeding nodes or bootstrap nodes help in this initial connection process.
#### List of active peers:

:::info
Copy and run the commands below to add your peers into `config.toml`.
:::

import LivePeers from '@site/src/components/LivePeers';

<LivePeers rpc="https://zetachain-rpc.f5nodes.com/net_info" />

```bash
Expand Down
21 changes: 14 additions & 7 deletions src/components/LivePeers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface LivePeersProps {

const LivePeers: React.FC<LivePeersProps> = ({ rpc }) => {
const [peers, setPeers] = useState<string>("");
const [isLoading, setIsLoading] = useState<boolean>(true);

useEffect(() => {
const fetchLivePeers = async () => {
Expand All @@ -25,21 +26,27 @@ const LivePeers: React.FC<LivePeersProps> = ({ rpc }) => {
});

setPeers(extractedPeers.join(", "));
setIsLoading(false);
} catch (error) {
console.error(`Failed to fetch peers info for RPC ${rpc}:`, error);
setIsLoading(false);
}
};

fetchLivePeers();
}, []);
}, [rpc]);

return (
<div>
<h4>
Live peers: <span>{peers.split(", ").length}</span>
</h4>
<CodeBlock language="bash">{`PEERS="${peers}"`}</CodeBlock>
</div>
<>
{isLoading ? (
<p>Loading live peers...</p>
) : (
<>
<h4>Live peers: {peers.split(", ").length}</h4>
<CodeBlock language="bash">{`PEERS="${peers}"`}</CodeBlock>
</>
)}
</>
);
};

Expand Down

0 comments on commit 1edc67b

Please sign in to comment.