-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathwatch.py
More file actions
executable file
·38 lines (31 loc) · 979 Bytes
/
watch.py
File metadata and controls
executable file
·38 lines (31 loc) · 979 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
36
37
38
#!/usr/bin/python3
import time
import requests
import logging
import sys
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logging.Formatter("[%(asctime)s]: %(message)s"))
logging.getLogger().addHandler(handler)
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
def check():
client = requests.Session()
client.trust_env = False
resp = client.get("http://127.0.0.1:8888/v1/chain/get_info").json()
local_head = resp["head_block_num"]
resp = client.get("https://wax.eoseoul.io/v1/chain/get_info").json()
mainnet_head = resp["head_block_num"]
diff = mainnet_head - local_head
log.info("local:{0} mainnet:{1} diff:{2}".format(local_head, mainnet_head, diff))
if diff <= 2:
log.info("synchronization is complete")
exit(0)
def main():
while True:
try:
check()
except Exception as e:
log.error(e)
time.sleep(10)
if __name__ == '__main__':
main()