コード例 #1
0
 def _get_slot(client: Client, index):
     endpoint = self.endpoints[index]
     num_retries = retries
     while num_retries > 0:
         try:
             response = client.get_slot(Commitment("finalized"))
             return response["result"]
         except Exception as e:
             logger.error(
                 f"solana_client_manager.py | get_slot, {e}",
                 exc_info=True,
             )
         num_retries -= 1
         time.sleep(DELAY_SECONDS)
         logger.error(
             f"solana_client_manager.py | get_slot | Retrying with endpoint {endpoint}"
         )
     raise Exception(
         f"solana_client_manager.py | get_slot | Failed with endpoint {endpoint}"
     )
コード例 #2
0
AUDIUS_PROGRAM = "Fm4g3bGuezevgqSHopjEDGRGCtVU6CDpFXZE3832EzGs"
SECP_PROGRAM = "KeccakSecp256k11111111111111111111111111111"

SLEEP_TIME = 3

# SOLANA_ENDPOINT = "https://devnet.solana.com"
SOLANA_ENDPOINT = "http://localhost:8899"

http_client = Client(SOLANA_ENDPOINT)

slot_from = None

while True:
    if not slot_from:
        slot_from = http_client.get_slot()["result"]

    transaction = http_client.get_confirmed_signature_for_address2(
        AUDIUS_PROGRAM, limit=1)

    if transaction["result"][0]["slot"] > slot_from:
        slot_from = transaction["result"][0]["slot"]
        tx_info = http_client.get_confirmed_transaction(
            transaction["result"][0]["signature"])
        if SECP_PROGRAM in tx_info["result"]["transaction"]["message"][
                "accountKeys"]:
            audius_program_index = tx_info["result"]["transaction"]["message"][
                "accountKeys"].index(AUDIUS_PROGRAM)
            for instruction in tx_info["result"]["transaction"]["message"][
                    "instructions"]:
                if instruction["programIdIndex"] == audius_program_index:
コード例 #3
0
from solana.rpc.api import Client

AUDIUS_PROGRAM = "Fs2Fmuo266ohhQjGRC6FCufjYaCHkuhyyRi3zn2xqrQP"
SECP_PROGRAM = "KeccakSecp256k11111111111111111111111111111"

SLEEP_TIME = 3

SOLANA_ENDPOINT = "https://devnet.solana.com"

http_client = Client(SOLANA_ENDPOINT)

slot_from = None

while True:
    if not slot_from:
        slot_from = http_client.get_slot()['result']

    transaction = http_client.get_confirmed_signature_for_address2(
        AUDIUS_PROGRAM, limit=1)

    if transaction['result'][0]['slot'] > slot_from:
        slot_from = transaction['result'][0]['slot']
        tx_info = http_client.get_confirmed_transaction(
            transaction['result'][0]['signature'])
        if SECP_PROGRAM in tx_info['result']['transaction']['message'][
                'accountKeys']:
            audius_program_index = tx_info['result']['transaction']['message'][
                'accountKeys'].index(AUDIUS_PROGRAM)
            for instruction in tx_info['result']['transaction']['message'][
                    'instructions']:
                if instruction['programIdIndex'] == audius_program_index: