Rpc Update
import requests
import toml
import subprocess
def update_bor_rpc_url(new_url):
config_file_path = "/path/to/your/config.toml"
try:
with open(config_file_path, "r") as config_file:
config = toml.load(config_file)
config["bor_rpc_url"] = new_url
with open(config_file_path, "w") as config_file:
toml.dump(config, config_file)
print("bor_rpc_url updated to:", new_url)
except Exception as e:
print("Error updating bor_rpc_url:", e)
def check_bor_sync_status():
bor_rpc_url = "http://localhost:8545"
try:
response = requests.post(bor_rpc_url, json={"jsonrpc": "2.0", "method": "eth_syncing", "params": [], "id": 1})
if response.status_code == 200:
data = response.json()
if "result" in data and data["result"] is False:
print("Bor is fully synchronized")
else:
new_bor_rpc_url = "https://your-bor-rpc"
update_bor_rpc_url(new_bor_rpc_url)
print("Bor is not fully synchronized. Updated bor_rpc_url.")
else:
print("Error in Bor RPC request - Status code:", response.status_code)
except requests.ConnectionError as ce:
print("Connection error while checking Bor sync status:", ce)
print("Attempting to update bor_rpc_url...")
new_bor_rpc_url = "https://mainnet.stakepool.dev.br/rpc"
update_bor_rpc_url(new_bor_rpc_url)
except Exception as e:
print("Error while checking Bor sync status:", e)
if __name__ == "__main__":
check_bor_sync_status()Last updated