Span Participation

The script retrieves information about the latest span, prompts the user for a validator ID, and checks if that validator is currently participating in the span. These operations aid in monitoring the involvement of a validator.

import os
import requests

# Check if the lock file already exists
if os.path.exists("lockfile"):

# Create the lock file
with open("lockfile", "w") as file:

def get_current_span_id():
        url = ""
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            span_id = data.get("result", {}).get("span_id")
            return span_id
            return None
    except Exception as e:
        return None

def check_validator_in_current_span(span_id, validator_id):
        url = f"{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."
            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)

    # Remove the lock file after program execution

Python and Requests Installation:

Make sure you have Python installed on your system. Open the terminal or command prompt. Execute the following command to install the requests library:

pip install requests

Script Execution:

Save the Python script ( in the directory of your choice. Place a file named "addresses.txt" in the same directory as the script, containing the addresses of the validators.

Run the Script:

In the terminal or command prompt, navigate to the directory where the script is located. Execute the script using the following command:



The script checks if the validator with the provided ID is among the validators of the current span.

Last updated