Skip to content

Commit

Permalink
peers count added
Browse files Browse the repository at this point in the history
  • Loading branch information
vasylcode authored Sep 6, 2023
1 parent 4d4706d commit 9f8ea1f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
6 changes: 1 addition & 5 deletions docs/zetachain/sync/peers-seeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ sidebar_position: 3
description: Live Peers / Seeds
---

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

<Highlight color="#25c2a0">Docusaurus green</Highlight>

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

<LivePeers />
<LivePeers rpc="https://zetachain-rpc.f5nodes.com/net_info" />
21 changes: 0 additions & 21 deletions src/components/Highlight/index.tsx

This file was deleted.

11 changes: 9 additions & 2 deletions src/components/LivePeers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ type Peer = {
port: string;
};

const LivePeers: React.FC = () => {
interface LivePeersProps {
rpc: string;
}

const LivePeers: React.FC<LivePeersProps> = ({ rpc }) => {
const [peers, setPeers] = useState<Peer[]>([]);

useEffect(() => {
const fetchLivePeers = async () => {
try {
const response = await fetch("https://zetachain-rpc.f5nodes.com/net_info");
const response = await fetch(rpc);
const data = await response.json();

const extractedPeers = data.result.peers.map((peer: any) => {
Expand All @@ -36,6 +40,9 @@ const LivePeers: React.FC = () => {
return (
<div>
<h2>Peers Information</h2>
<h4>
All peers: <span>{peers.length}</span>
</h4>
<ul>
{peers.map((peer) => (
<li key={peer.id}>
Expand Down

0 comments on commit 9f8ea1f

Please sign in to comment.