forked from itzmeanjan/harmony
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscribe_7.py
More file actions
35 lines (28 loc) · 764 Bytes
/
subscribe_7.py
File metadata and controls
35 lines (28 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python3
from python_graphql_client import GraphqlClient
from json import dumps
import asyncio
def prettyPrint(data):
print(dumps(data, sort_keys=True, indent=2))
try:
client = GraphqlClient(endpoint="ws://localhost:7000/v1/graphql")
query = """
subscription {
pendingPool {
from
to
nonce
gas
gasPrice
queuedFor
pendingFor
pool
}
}
"""
print('Listening for any new tx, entering/ leaving pending pool')
asyncio.run(client.subscribe(query=query, handle=prettyPrint))
except Exception as e:
print(e)
except KeyboardInterrupt:
print('\nStopping')