-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_usage.py
More file actions
38 lines (32 loc) · 965 Bytes
/
basic_usage.py
File metadata and controls
38 lines (32 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from nodepulse import NodePulse
import requests
import time
import json
def check_chain_info():
try:
# Get a healthy node
node = node_pulse.get_node()
print(f"\nUsing node: {node}")
# Get chain info
response = requests.get(f"{node}/v1/chain/get_info")
chain_info = response.json()
print(f"Chain info: {json.dumps(chain_info, indent=2)}")
except Exception as error:
print(f"Failed to get chain info: {str(error)}")
# Initialize NodePulse with default options
node_pulse = NodePulse(
node_type='hyperion',
network='mainnet',
node_count=3,
update_interval=10000 # Set to 10 seconds for testing
)
# Initial check
check_chain_info()
# Keep checking every 10 seconds
try:
print("\nChecking chain info every 10 seconds (press Ctrl+C to exit)...")
while True:
time.sleep(10)
check_chain_info()
except KeyboardInterrupt:
print("\nExiting...")