@log_exceptions
async def add_peer(self, connect_str: str) -> Peer:
    (node_id, rest) = extract_nodeid(connect_str)
    peer = self._peers.get(node_id)
    if (not peer):
        if (rest is not None):
            (host, port) = split_host_port(rest)
        elif (not self.channel_db):
            addr = trampolines_by_id().get(node_id)
            if (not addr):
                raise ConnStringFormatError(((_('Address unknown for node:') + ' ') + bh2u(node_id)))
            (host, port) = (addr.host, addr.port)
        else:
            addrs = self.channel_db.get_node_addresses(node_id)
            if (not addrs):
                raise ConnStringFormatError(((_("Don't know any addresses for node:") + ' ') + bh2u(node_id)))
            (host, port, timestamp) = self.choose_preferred_address(list(addrs))
        port = int(port)
        try:
            (await asyncio.get_event_loop().getaddrinfo(host, port))
        except socket.gaierror:
            raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)'))
        peer = (await self._add_peer(host, port, node_id))
    return peer
@log_exceptions
async def add_peer(self, connect_str: str) -> Peer:
    (node_id, rest) = extract_nodeid(connect_str)
    peer = self._peers.get(node_id)
    if (not peer):
        if (rest is not None):
            (host, port) = split_host_port(rest)
        elif (not self.channel_db):
            addr = trampolines_by_id().get(node_id)
            if (not addr):
                raise ConnStringFormatError(((_('Address unknown for node:') + ' ') + bh2u(node_id)))
            (host, port) = (addr.host, addr.port)
        else:
            addrs = self.channel_db.get_node_addresses(node_id)
            if (not addrs):
                raise ConnStringFormatError(((_("Don't know any addresses for node:") + ' ') + bh2u(node_id)))
            (host, port, timestamp) = self.choose_preferred_address(list(addrs))
        port = int(port)
        try:
            (await asyncio.get_event_loop().getaddrinfo(host, port))
        except socket.gaierror:
            raise ConnStringFormatError(_('Hostname does not resolve (getaddrinfo failed)'))
        peer = (await self._add_peer(host, port, node_id))
    return peer