Exemple #1
0
def create_local_pool(node_base_dir, cli_base_dir, config=None, node_size=4):
    conf = config or getConfig()

    stewards = []
    node_conf = []
    nodes = []
    genesis_txns = []
    for i in range(node_size):
        w = Wallet("steward")
        s = Steward(wallet=w)
        s.wallet.addIdentifier()

        stewards.append(s)

        node_config_helper = NodeConfigHelper(conf.name,
                                              conf,
                                              chroot=node_base_dir)
        n_config = adict(name='Node' + str(i + 1),
                         basedirpath=node_config_helper.ledger_dir,
                         ha=('127.0.0.1', 9700 + (i * 2)),
                         cliha=('127.0.0.1', 9700 + (i * 2) + 1))

        n_verkey, n_bls_key, n_bls_key_proof = \
            initialize_node_environment(name=n_config.name,
                                        node_config_helper=node_config_helper,
                                        override_keep=True,
                                        sigseed=randomSeed())

        s.set_node(n_config,
                   verkey=n_verkey,
                   blskey=n_bls_key,
                   blsley_proof=n_bls_key_proof)

        node_conf.append(n_config)

        genesis_txns += s.generate_genesis_txns()

    pool = None  # LocalPool(genesis_txns, pool_dir, steward=stewards[0])

    for c in node_conf:
        n = Node(**c)
        pool.add(n)
        nodes.append(n)

    pool.runFor(5)

    return pool
Exemple #2
0
def create_local_pool(base_dir, node_size=4):
    conf = getConfig(base_dir)
    pool_dir = os.path.join(base_dir, "pool")

    # TODO: Need to come back to this why we need this cleanup
    shutil.rmtree(pool_dir, ignore_errors=True)

    stewards = []
    node_conf = []
    nodes = []
    genesis_txns = []
    for i in range(node_size):
        w = Wallet("steward")
        s = Steward(wallet=w)
        s.wallet.addIdentifier()

        stewards.append(s)

        n_config = adict(name='Node' + str(i + 1),
                         basedirpath=pool_dir,
                         ha=('127.0.0.1', 9700 + (i * 2)),
                         cliha=('127.0.0.1', 9700 + (i * 2) + 1))

        n_verkey, n_bls_key = initialize_node_environment(
            name=n_config.name,
            base_dir=n_config.basedirpath,
            override_keep=True,
            config=conf,
            sigseed=randomSeed())

        s.set_node(n_config, verkey=n_verkey, blskey=n_bls_key)

        node_conf.append(n_config)

        genesis_txns += s.generate_genesis_txns()

    pool = LocalPool(genesis_txns, pool_dir, steward=stewards[0])

    for c in node_conf:
        n = Node(**c)
        pool.add(n)
        nodes.append(n)

    pool.runFor(5)

    return pool
Exemple #3
0
def create_local_pool(base_dir, node_size=4):
    conf = getConfig(base_dir)
    pool_dir = os.path.join(base_dir, "pool")

    # TODO: Need to come back to this why we need this cleanup
    shutil.rmtree(pool_dir, ignore_errors=True)

    stewards = []
    node_conf = []
    nodes = []
    genesis_txns = []
    for i in range(node_size):
        w = Wallet("steward")
        s = Steward(wallet=w)
        s.wallet.addIdentifier()

        stewards.append(s)

        n_config = adict(name='Node'+str(i+1),
                         basedirpath=pool_dir,
                         ha=('127.0.0.1', 9700+(i * 2)),
                         cliha=('127.0.0.1', 9700+(i * 2)+1))

        n_verkey = initialize_node_environment(name=n_config.name,
                                               base_dir=n_config.basedirpath,
                                               override_keep=True,
                                               config=conf,
                                               sigseed=randomSeed())

        s.set_node(n_config, verkey=n_verkey)

        node_conf.append(n_config)

        genesis_txns += s.generate_genesis_txns()

    pool = LocalPool(genesis_txns, pool_dir, steward=stewards[0])

    for c in node_conf:
        n = Node(**c)
        pool.add(n)
        nodes.append(n)

    pool.runFor(5)

    return pool
Exemple #4
0
def create_local_pool(node_base_dir, cli_base_dir, config=None, node_size=4):
    conf = config or getConfig()

    stewards = []
    node_conf = []
    nodes = []
    genesis_txns = []
    for i in range(node_size):
        w = Wallet("steward")
        s = Steward(wallet=w)
        s.wallet.addIdentifier()

        stewards.append(s)

        node_config_helper = NodeConfigHelper(conf.name, conf, chroot=node_base_dir)
        n_config = adict(name='Node' + str(i + 1),
                         basedirpath=node_config_helper.ledger_dir,
                         ha=('127.0.0.1', 9700 + (i * 2)),
                         cliha=('127.0.0.1', 9700 + (i * 2) + 1))

        n_verkey, n_bls_key = initialize_node_environment(name=n_config.name,
                                                          node_config_helper=node_config_helper,
                                                          override_keep=True,
                                                          sigseed=randomSeed())

        s.set_node(n_config, verkey=n_verkey, blskey=n_bls_key)

        node_conf.append(n_config)

        genesis_txns += s.generate_genesis_txns()

    pool = None  # LocalPool(genesis_txns, pool_dir, steward=stewards[0])

    for c in node_conf:
        n = Node(**c)
        pool.add(n)
        nodes.append(n)

    pool.runFor(5)

    return pool