-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.py
41 lines (31 loc) · 1020 Bytes
/
demo.py
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
39
40
41
import kth
import signal
import asyncio
running_ = False
def shutdown(sig, frame):
global running_
print('Graceful shutdown ...')
running_ = False
async def main():
global running_
signal.signal(signal.SIGINT, shutdown)
config = kth.config.getDefault(kth.config.Network.mainnet)
with kth.node.Node(config, True) as node:
await node.launch(kth.primitives.StartModules.all)
print("Knuth node has been launched.")
running_ = True
(_, height) = await node.chain.getLastHeight()
print(f"Current height in local copy: {height}")
if await comeBackAfterTheBCHHardFork(node):
print("Bitcoin Cash has been created!")
# node.close()
print("Good bye!")
async def comeBackAfterTheBCHHardFork(node):
hfHeight = 478559
while running_:
(_, height) = await node.chain.getLastHeight()
if height >= hfHeight:
return True
await asyncio.sleep(10)
return False
asyncio.run(main())