speed_simulation.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:raiden 作者: raiden-network 项目源码 文件源码
def random_raiden_network(
        token_address,
        blockchain_service,
        node_addresses,
        deposit,
        settle_timeout):
    """ Creates random channels among the test nodes until we have a connected graph. """
    graph = networkx.Graph()
    graph.add_nodes_from(node_addresses)

    for edge in blockchain_service.addresses_by_token(token_address):
        graph.add_edge(edge[0], edge[1])

    while not networkx.is_connected(graph):
        from_address = random.choice(node_addresses)
        to_address = random.choice(node_addresses)

        netcontract_address = blockchain_service.new_netting_contract(
            token_address,
            from_address,
            to_address,
            settle_timeout,
        )

        blockchain_service.deposit(
            token_address,
            netcontract_address,
            from_address,
            deposit,
        )

        blockchain_service.deposit(
            token_address,
            netcontract_address,
            to_address,
            deposit,
        )

        graph.add_edge(from_address, to_address)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号