コード例 #1
0
ファイル: main.py プロジェクト: scoutsaachi/zatt
def run():
    """Start a node.
        e.g python3 main.py /Users/saachi/Desktop/cs244b/zatt/zatt_cluster/config.json 1 --debug True
    """
    parser = argparse.ArgumentParser(description='Start node for Raft BFT')
    parser.add_argument('configFile', type=str, help='the configuration file')
    parser.add_argument('id', type=int, help='the node id to be started')
    parser.add_argument('--debug',type=bool, default=False, help="print debugger log")
    args = parser.parse_args()
    config = Config.CreateConfig(args.configFile, args.id, args.debug)
    server = setup(config)
    loop = asyncio.get_event_loop()
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass

    # # Close the server
    server.close()
    loop.run_until_complete(server.wait_closed())
    loop.close()
コード例 #2
0
def createClientDict(addr, port, config):
    config = Config.CreateConfig(config, -1, False)
    return DistributedDict(addr, port, config.cluster, config.private_key)