Ejemplo n.º 1
0
def create_app(
    privatekey_bin,
    chain,
    discovery,
    transport_class,
    send_ping_time,
    max_unresponsive_time,
    port,
    reveal_timeout,
    settle_timeout,
    database_path,
    host='127.0.0.1',
):
    ''' Instantiates an Raiden app with the given configuration. '''
    config = copy.deepcopy(App.default_config)

    config['port'] = port
    config['host'] = host
    config['privatekey_hex'] = privatekey_bin.encode('hex')
    config['send_ping_time'] = send_ping_time
    config['max_unresponsive_time'] = max_unresponsive_time
    config['reveal_timeout'] = reveal_timeout
    config['settle_timeout'] = settle_timeout
    config['database_path'] = database_path

    app = App(
        config,
        chain,
        discovery,
        transport_class,
    )
    app.raiden.protocol.transport.throttle_policy = DummyPolicy()
    return app
Ejemplo n.º 2
0
    def __init__(self,
                 host,
                 port,
                 protocol=None,
                 throttle_policy=DummyPolicy()):

        super().__init__(host, port, protocol, throttle_policy)
        self.droprate = 0
Ejemplo n.º 3
0
    def __init__(self,
                 host,
                 port,
                 protocol=None,
                 throttle_policy=DummyPolicy()):

        super().__init__(host, port, protocol, throttle_policy)
        self.addresses_to_messages = dict()
Ejemplo n.º 4
0
    def __init__(self,
                 host,
                 port,
                 protocol=None,
                 throttle_policy=DummyPolicy()):

        super(UnreliableTransport, self).__init__(host, port, protocol,
                                                  throttle_policy)
        self.droprate = 0
Ejemplo n.º 5
0
def create_apps(blockchain_services, endpoint_discovery_services,
                registry_address, raiden_udp_ports, transport_class,
                reveal_timeout, settle_timeout, database_paths, retry_interval,
                retries_before_backoff, throttle_capacity, throttle_fill_rate,
                nat_invitation_timeout, nat_keepalive_retries,
                nat_keepalive_timeout):
    """ Create the apps."""
    # pylint: disable=too-many-locals
    services = zip(blockchain_services, endpoint_discovery_services)

    apps = []
    for idx, (blockchain, discovery) in enumerate(services):
        port = raiden_udp_ports[idx]
        private_key = blockchain.private_key
        nodeid = privatekey_to_address(private_key)

        host = '127.0.0.1'

        discovery.register(nodeid, host, port)

        config = {
            'host': host,
            'port': port,
            'external_ip': host,
            'external_port': port,
            'privatekey_hex': hexlify(private_key),
            'reveal_timeout': reveal_timeout,
            'settle_timeout': settle_timeout,
            'database_path': database_paths[idx],
            'protocol': {
                'retry_interval': retry_interval,
                'retries_before_backoff': retries_before_backoff,
                'throttle_capacity': throttle_capacity,
                'throttle_fill_rate': throttle_fill_rate,
                'nat_invitation_timeout': nat_invitation_timeout,
                'nat_keepalive_retries': nat_keepalive_retries,
                'nat_keepalive_timeout': nat_keepalive_timeout,
            },
            'rpc': True,
            'console': False,
        }
        copy = App.DEFAULT_CONFIG.copy()
        copy.update(config)

        registry = blockchain.registry(registry_address)

        app = App(
            copy,
            blockchain,
            registry,
            discovery,
            transport_class,
        )
        app.raiden.protocol.transport.throttle_policy = DummyPolicy()
        apps.append(app)

    return apps
Ejemplo n.º 6
0
def create_apps(blockchain_services, endpoint_discovery_services,
                raiden_udp_ports, transport_class, reveal_timeout,
                settle_timeout, database_paths, retry_interval,
                retries_before_backoff, throttle_capacity, throttle_fill_rate,
                nat_invitation_timeout, nat_keepalive_retries,
                nat_keepalive_timeout):
    """ Create the apps.

    Note:
        The generated network will use two subnets, 127.0.0.10 and 127.0.0.11,
        for this test to work in a mac both virtual interfaces must be created
        prior to the test execution::

            MacOSX (tested on 10.11.5):
                         interface       ip address netmask
                ifconfig lo0       alias 127.0.0.10 255.255.255.0
                ifconfig lo0       alias 127.0.0.11 255.255.255.0

            Alternative syntax:
                ifconfig lo:0 127.0.0.10
                ifconfig lo:1 127.0.0.11
    """
    # pylint: disable=too-many-locals
    half_of_nodes = len(blockchain_services) // 2

    services = zip(blockchain_services, endpoint_discovery_services)

    apps = []
    for idx, (blockchain, discovery) in enumerate(services):
        port = raiden_udp_ports[idx]
        private_key = blockchain.private_key
        nodeid = privatekey_to_address(private_key)

        # split the nodes into two different networks
        if idx > half_of_nodes:
            # TODO: check if the loopback interfaces exists
            host = '127.0.0.11'
        else:
            host = '127.0.0.10'

        discovery.register(nodeid, host, port)

        config = {
            'host': host,
            'port': port,
            'external_ip': host,
            'external_port': port,
            'privatekey_hex': private_key.encode('hex'),
            'reveal_timeout': reveal_timeout,
            'settle_timeout': settle_timeout,
            'database_path': database_paths[idx],
            'protocol': {
                'retry_interval': retry_interval,
                'retries_before_backoff': retries_before_backoff,
                'throttle_capacity': throttle_capacity,
                'throttle_fill_rate': throttle_fill_rate,
                'nat_invitation_timeout': nat_invitation_timeout,
                'nat_keepalive_retries': nat_keepalive_retries,
                'nat_keepalive_timeout': nat_keepalive_timeout,
            },
            'rpc': True,
            'console': False,
        }
        copy = App.DEFAULT_CONFIG.copy()
        copy.update(config)

        app = App(
            copy,
            blockchain,
            discovery,
            transport_class,
        )
        app.raiden.protocol.transport.throttle_policy = DummyPolicy()
        apps.append(app)

    return apps