Span Participation
import os
import requests
if os.path.exists("lockfile"):
exit()
with open("lockfile", "w") as file:
file.write("")
def get_current_span_id():
try:
url = "https://heimdall-api.polygon.technology/bor/latest-span"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
span_id = data.get("result", {}).get("span_id")
return span_id
else:
return None
except Exception as e:
return None
def check_validator_in_current_span(span_id, validator_id):
try:
url = f"https://heimdall-api.polygon.technology/bor/span/{span_id}"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
selected_producers = data.get("result", {}).get("validator_set", {}).get("validators", [])
for validator in selected_producers:
if validator["ID"] == validator_id:
return "The validator is part of the current span."
return "The validator is NOT part of the current span."
else:
return "Error fetching current span information."
except Exception as e:
return "Error checking validator in the current span."
if __name__ == "__main__":
validator_id = int(input("Enter the validator ID: "))
current_span_id = get_current_span_id()
if current_span_id is not None:
response = check_validator_in_current_span(current_span_id, validator_id)
print(response)
os.remove("lockfile")Last updated