Esempio n. 1
0
def setup_matrix(
    transport_config: MatrixTransportConfig,
    services_config: ServiceConfig,
    environment_type: Environment,
    routing_mode: RoutingMode,
) -> MatrixTransport:
    if transport_config.server == MATRIX_AUTO_SELECT_SERVER:
        # fetch list of known servers from raiden-network/raiden-tranport repo
        available_servers_url = DEFAULT_MATRIX_KNOWN_SERVERS[environment_type]

        log.debug("Fetching available matrix servers")
        available_servers = get_matrix_servers(available_servers_url)
        log.debug("Available matrix servers", available_servers=available_servers)

        transport_config.available_servers = available_servers

    # Add PFS broadcast room when not in private mode
    if routing_mode != RoutingMode.PRIVATE:
        if PATH_FINDING_BROADCASTING_ROOM not in transport_config.broadcast_rooms:
            transport_config.broadcast_rooms.append(PATH_FINDING_BROADCASTING_ROOM)

    # Add monitoring service broadcast room if enabled
    if services_config.monitoring_enabled is True:
        transport_config.broadcast_rooms.append(MONITORING_BROADCASTING_ROOM)

    return MatrixTransport(config=transport_config, environment=environment_type)
Esempio n. 2
0
def fetch_available_matrix_servers(transport_config: MatrixTransportConfig,
                                   environment_type: Environment) -> None:
    """
    Fetches the list of known servers from raiden-network/raiden-tranport repo
    for the given environment.
    """
    available_servers_url = DEFAULT_MATRIX_KNOWN_SERVERS[environment_type]

    log.debug("Fetching available matrix servers")
    available_servers = get_matrix_servers(available_servers_url)
    log.debug("Available matrix servers", available_servers=available_servers)

    transport_config.available_servers = available_servers