-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_validators_testnet.py
More file actions
35 lines (22 loc) · 938 Bytes
/
update_validators_testnet.py
File metadata and controls
35 lines (22 loc) · 938 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
# coding: utf-8
import config
import re
import os
import requests
from lib.rpc import get_epoch
GITHUB_URL = str("https://raw.githubusercontent.com/solana-labs/stake-o-matic/"
"master/bot/src/validator_list.rs")
# GITHUB_URL = str("https://raw.githubusercontent.com/solana-labs/stake-o-matic/dfb0b8f56b64170c5fa5d47f660317beadaf37fb/bot/src/validator_list.rs")
RE_PUBKEY = re.compile(r'"([a-zA-Z0-9]+)?",')
DIR_TESTNET_VALIDATORS = "data/validators-testnet"
def update_validators_testnet():
""" Update testnet validators list
"""
os.makedirs(DIR_TESTNET_VALIDATORS, exist_ok=True)
epoch_no = get_epoch(cluster_rpc=config.RPC_TESTNET)
html = requests.get(GITHUB_URL).text
with open(f"{DIR_TESTNET_VALIDATORS}/{epoch_no}.txt", "w+") as w:
for tn_pubkey in RE_PUBKEY.findall(html):
w.write(f"{tn_pubkey}\n")
if __name__ == "__main__":
update_validators_testnet()