Words
63
Reading
1 min
Listen
Play
6y
Manage nodes that does not support TRX Lookups
This feature is very usefull, but some nodes has lookup by TRX disbaled, making the example code above crash and fail. With a few minor changes we can handle these issues.
import beemapi
.....
while not trx_id_found and delay < 120:
print("- Checking trx_id....")
try:
trx_id_found = hiveBlockchain.is_transaction_existing(trx_id)
except beemapi.exceptions.RPCError as err:
old_node_url = hive.rpc.url
hive.rpc.next()
new_node_url = hive.rpc.url
print("Caught RPC Error: %s " % (err))
print("Switching from %s to %s" % (old_node_url, new_node_url))
time.sleep(10)
delay += 10
if not trx_id_found:
print("- Cound not broadcast!")
.....
What this code does is that if we have an exception with "RPCError" we will switch node to the next one.
Example Output
- Checking trx_id....
Caught RPC Error: Assert Exception:false: This node's operator has disabled operation indexing by transaction_id
Switching from https://rpc.ausbit.dev to https://hive.roelandp.nl
- Checking trx_id....
- Checking trx_id....
RE: update for beem: transaction id is returned when broadcasting