Esempio n. 1
0
def domain_setup_utility(core_port_increment, dom_id, host=None):
    if host is None:
        cl = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT + core_port_increment, multiq=False)
    else:
        cl = bbc_app.BBcAppClient(host=host, port=DEFAULT_CORE_PORT + core_port_increment, multiq=False)
    working_dir = ".bbc1-%i/" % (DEFAULT_CORE_PORT + core_port_increment)
    cl.domain_setup(dom_id)
    global common_domain_id
    common_domain_id = dom_id
    wait_check_result_msg_type(cl.callback, bbclib.MsgType.RESPONSE_SETUP_DOMAIN)
    cl.unregister_from_core()
Esempio n. 2
0
def start_server(host="127.0.0.1", cport=9000, wport=3000):
    global bbcapp
    bbcapp = bbc_app.BBcAppClient(host=host, port=cport)
    #context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
    #context.load_cert_chain(os.path.join(argresult.ssl, "cert1.pem"), os.path.join(argresult.ssl, "privkey1.pem"))
    #http.run(host='0.0.0.0', port=argresult.waitport, ssl_context=context)
    http.run(host='0.0.0.0', port=wport)
Esempio n. 3
0
def make_client(index,
                core_port_increment,
                callback=None,
                connect_to_core=True,
                domain_id=None,
                id_length=bbclib.DEFAULT_ID_LEN):
    keypair = bbclib.KeyPair()
    keypair.generate()
    clients[index]['user_id'] = bbclib.get_new_id("user_%i" %
                                                  index)[:id_length]
    clients[index]['keypair'] = keypair
    clients[index]['app'] = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT +
                                                 core_port_increment,
                                                 multiq=False,
                                                 id_length=id_length)
    if connect_to_core:
        if domain_id is None:
            global common_domain_id
            domain_id = common_domain_id
        clients[index]['app'].set_user_id(clients[index]['user_id'])
        clients[index]['app'].set_domain_id(domain_id)
    if callback is not None:
        clients[index]['app'].set_callback(callback)
    working_dir = ".bbc1-%i/" % (DEFAULT_CORE_PORT + core_port_increment)
    time.sleep(0.1)
    print("[%i] user_id = %s" %
          (index, binascii.b2a_hex(clients[index]['user_id'])))
Esempio n. 4
0
def make_client_direct(index, host, port, callback=None, domain_id=None, id_length=bbclib.DEFAULT_ID_LEN):
    keypair = bbclib.KeyPair()
    keypair.generate()
    clients[index]['user_id'] = bbclib.get_new_id("user_%i" % index)[:id_length]
    clients[index]['keypair'] = keypair
    clients[index]['app'] = bbc_app.BBcAppClient(host=host, port=port, multiq=False, id_length=id_length)
    if domain_id is None:
        global common_domain_id
        domain_id = common_domain_id
    clients[index]['app'].set_user_id(clients[index]['user_id'])
    clients[index]['app'].set_domain_id(domain_id)
    if callback is not None:
        clients[index]['app'].set_callback(callback)
    time.sleep(0.1)
    print("[%i] user_id = %s" % (index, binascii.b2a_hex(clients[index]['user_id'])))
Esempio n. 5
0
    argparser = ArgumentParser(usage=usage)
    argparser.add_argument('-a', '--address', type=str, default='localhost', help='bbc_core address')
    argparser.add_argument('--port', type=int, default=9000, help='bbc_core port')
    argparser.add_argument('-l', '--loop', type=int, default=1000, help='loop count')
    argparser.add_argument('-c', '--clients', type=int, default=3, help='loop count')
    argparser.add_argument('-t', '--type', type=int, default=0, help='format_type')
    args = argparser.parse_args()
    return args


if __name__ == "__main__":
    parsed_args = parser()
    for i in range(parsed_args.clients):
        user_ids.append(bbclib.get_new_id("user_id_%d" % i)[:bbclib.DEFAULT_ID_LEN])
        keypairs.append(bbclib.KeyPair())
        keypairs[i].generate()

    app = bbc_app.BBcAppClient(host=parsed_args.address, port=parsed_args.port, multiq=False, id_length=bbclib.DEFAULT_ID_LEN)

    app.set_user_id(user_ids[0])
    app.register_to_core()
    app.set_domain_id(domain_id)
    app.domain_setup(domain_id)
    dat = app.callback.synchronize()

    print("***** format_type = %d ******" % parsed_args.type)
    txobjs = make_transactions(fmt=parsed_args.type, count=parsed_args.loop)

    insert_transactions(app, txobjs)