let example node.py run as second node server
This commit is contained in:
parent
1194bda2ad
commit
5053e5e61c
@ -24,10 +24,21 @@ def parse_arguments():
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
async def connect_to_bootstrap_node(args):
|
def connect_to_bootstrap_node(args):
|
||||||
await server.listen(8469)
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.set_debug(True)
|
||||||
|
|
||||||
|
loop.run_until_complete(server.listen(8469))
|
||||||
bootstrap_node = (args.ip, int(args.port))
|
bootstrap_node = (args.ip, int(args.port))
|
||||||
await server.bootstrap([bootstrap_node])
|
loop.run_until_complete(server.bootstrap([bootstrap_node]))
|
||||||
|
|
||||||
|
try:
|
||||||
|
loop.run_forever()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
server.stop()
|
||||||
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
def create_bootstrap_node():
|
def create_bootstrap_node():
|
||||||
@ -49,7 +60,7 @@ def main():
|
|||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
|
|
||||||
if args.ip and args.port:
|
if args.ip and args.port:
|
||||||
asyncio.run(connect_to_bootstrap_node(args))
|
connect_to_bootstrap_node(args)
|
||||||
else:
|
else:
|
||||||
create_bootstrap_node()
|
create_bootstrap_node()
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
import hashlib
|
import hashlib
|
||||||
|
# pylint: disable=no-name-in-module
|
||||||
from struct import pack
|
from struct import pack
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
Loading…
Reference in New Issue
Block a user