func (h *Handler) Endpoint(key data.Base64String) (*data.Base64String, error) {
	logger := h.logger.Add("type", "agent/tor-somc.Handler")

	channelsStructs, err := h.db.SelectAllFrom(data.ChannelTable, "")
	if err != nil {
		h.logger.Error(err.Error())
		return nil, ErrInternal
	}

	for _, chanStruct := range channelsStructs {
		channel := chanStruct.(*data.Channel)
		channelKey, err := h.channelKey(logger, channel)
		if err != nil {
			h.logger.Error(err.Error())
			return nil, ErrInternal
		}
		if channelKey == key {
			endpoint, err := h.endpointByChannelID(logger, channel.ID)
			if err != nil {
				return nil, err
			}
			return &endpoint.RawMsg, nil
		}
	}

	return nil, ErrChannelNotFound
}
func (h *Handler) Endpoint(key data.Base64String) (*data.Base64String, error) {
	logger := h.logger.Add("type", "agent/tor-somc.Handler")

	channelsStructs, err := h.db.SelectAllFrom(data.ChannelTable, "")
	if err != nil {
		h.logger.Error(err.Error())
		return nil, ErrInternal
	}

	for _, chanStruct := range channelsStructs {
		channel := chanStruct.(*data.Channel)
		channelKey, err := h.channelKey(logger, channel)
		if err != nil {
			h.logger.Error(err.Error())
			return nil, ErrInternal
		}
		if channelKey == key {
			endpoint, err := h.endpointByChannelID(logger, channel.ID)
			if err != nil {
				return nil, err
			}
			return &endpoint.RawMsg, nil
		}
	}

	return nil, ErrChannelNotFound
}
// Endpoint returns endpoint msg for a channel with given key.