def full_genesis(ctx, hosts, nodes_per_host, scenario):
    # pylint: disable=too-many-locals

    pretty = ctx.obj['pretty']
    node_list = build_node_list(hosts, nodes_per_host)

    accounts = generate_accounts(node_list)  # pylint: disable=redefined-outer-name

    all_addresses = [
        account['address'] for account in accounts.values()
    ]

    genesis = mk_genesis(all_addresses)  # pylint: disable=redefined-outer-name

    if scenario is not None:
        with open(scenario) as handler:
            script = json.load(handler)

        token_groups = {
            asset['name']: asset['channels']
            for asset in script['assets']
        }
    else:
        # create tokens for addresses x addresses
        token_groups = {
            account['address']: all_addresses
            for account in accounts.values()
        }

    dump, blockchain_config = deploy_all(token_groups=token_groups)

    for account, data in dump.items():
        if account not in genesis['alloc']:
            genesis['alloc'][account] = data

    genesis['config']['raidenFlags'] = blockchain_config['raiden_flags']
    genesis['config']['token_groups'] = blockchain_config['token_groups']

    if scenario is not None:
        for asset in script['assets']:
            asset['token_address'] = blockchain_config['token_groups'][asset['name']]

        with open(scenario, 'w') as handler:
            json.dump(script, handler)

    print json.dumps(genesis, indent=2 if pretty else None)
Beispiel #2
0
def full_genesis(ctx, hosts, nodes_per_host, scenario):
    # pylint: disable=too-many-locals

    pretty = ctx.obj['pretty']
    node_list = build_node_list(hosts, nodes_per_host)

    accounts = generate_accounts(node_list)  # pylint: disable=redefined-outer-name

    all_addresses = [
        account['address'] for account in accounts.values()
    ]

    genesis = mk_genesis(all_addresses)  # pylint: disable=redefined-outer-name

    if scenario is not None:
        with open(scenario) as handler:
            script = json.load(handler)

        token_groups = {
            token['name']: token['channels']
            for token in script['tokens']
        }
    else:
        # create tokens for addresses x addresses
        token_groups = {
            account['address']: all_addresses
            for account in accounts.values()
        }

    dump, blockchain_config = deploy_all(token_groups=token_groups)

    for account, data in dump.items():
        if account not in genesis['alloc']:
            genesis['alloc'][account] = data

    genesis['config']['raidenFlags'] = blockchain_config['raiden_flags']
    genesis['config']['token_groups'] = blockchain_config['token_groups']

    if scenario is not None:
        for token in script['tokens']:
            token['token_address'] = blockchain_config['token_groups'][token['name']]

        with open(scenario, 'w') as handler:
            json.dump(script, handler)

    print(json.dumps(genesis, indent=2 if pretty else None))
Beispiel #3
0
def full_genesis(ctx, hosts, nodes_per_host, scenario):
    pretty = ctx.obj['pretty']
    node_list = build_node_list(hosts, nodes_per_host)
    accounts = generate_accounts(node_list)
    genesis = mk_genesis([acc['address'] for acc in accounts.values()])

    if scenario is not None:
        with open(scenario) as f:
            script = json.load(f)
        token_groups = {
            asset['name']: asset['channels']
            for asset in script['assets']
        }
    else:
        # create tokens for addresses x addresses
        token_groups = {
            account['address']: [acc['address'] for acc in accounts.values()]
            for account in accounts.values()
        }

    dump, blockchain_config = deploy_all(token_groups=token_groups)

    for account, data in dump.items():
        if not account in genesis['alloc']:
            genesis['alloc'][account] = data

    genesis['config']['raidenFlags'] = blockchain_config['raiden_flags']
    genesis['config']['token_groups'] = blockchain_config['token_groups']

    if scenario is not None:
        for asset in script['assets']:
            asset['token_address'] = blockchain_config['token_groups'][
                asset['name']]
        with open(scenario, 'w') as f:
            json.dump(script, f)

    print json.dumps(genesis, indent=2 if pretty else None)