ui/offering.go
func (h *Handler) AcceptOffering(tkn string, account data.HexString,
	offering string, deposit, gasPrice uint64) (*string, error) {
	logger := h.logger.Add("method", "AcceptOffering",
		"account", account, "offering", offering,
		"deposit", deposit, "gasPrice", gasPrice)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	var acc data.Account
	if err := h.findByColumn(logger, ErrAccountNotFound,
		&acc, "eth_addr", account); err != nil {
		return nil, err
	}

	offer, err := h.findActiveOfferingByID(logger, offering)
	if err != nil {
		return nil, err
	}

	minDeposit := data.MinDeposit(offer)

	if deposit == 0 {
		deposit = minDeposit
	} else if deposit < minDeposit {
		logger.Error(ErrDepositTooSmall.Error())
		return nil, ErrDepositTooSmall
	}

	if err := h.pingOffering(logger, offer); err != nil {
		return nil, err
	}

	rid := util.NewUUID()
	jobData := &worker.ClientPreChannelCreateData{Account: acc.ID,
		Offering: offering, GasPrice: gasPrice, Deposit: deposit}
	if err := job.AddWithData(h.queue, nil, data.JobClientPreChannelCreate,
		data.JobChannel, rid, data.JobUser, jobData); err != nil {
		logger.Error(err.Error())
		return nil, ErrInternal
	}

	return &rid, nil
}
func (h *Handler) AcceptOffering(tkn string, account data.HexString,
	offering string, deposit, gasPrice uint64) (*string, error) {
	logger := h.logger.Add("method", "AcceptOffering",
		"account", account, "offering", offering,
		"deposit", deposit, "gasPrice", gasPrice)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	var acc data.Account
	if err := h.findByColumn(logger, ErrAccountNotFound,
		&acc, "eth_addr", account); err != nil {
		return nil, err
	}

	offer, err := h.findActiveOfferingByID(logger, offering)
	if err != nil {
		return nil, err
	}

	minDeposit := data.MinDeposit(offer)

	if deposit == 0 {
		deposit = minDeposit
	} else if deposit < minDeposit {
		logger.Error(ErrDepositTooSmall.Error())
		return nil, ErrDepositTooSmall
	}

	if err := h.pingOffering(logger, offer); err != nil {
		return nil, err
	}

	rid := util.NewUUID()
	jobData := &worker.ClientPreChannelCreateData{Account: acc.ID,
		Offering: offering, GasPrice: gasPrice, Deposit: deposit}
	if err := job.AddWithData(h.queue, nil, data.JobClientPreChannelCreate,
		data.JobChannel, rid, data.JobUser, jobData); err != nil {
		logger.Error(err.Error())
		return nil, ErrInternal
	}

	return &rid, nil
}
func ( h * Handler ) AcceptOffering ( tkn string , account data . HexString , offering string , deposit , gasPrice uint64 ) ( * string , error ) { logger := h . logger . Add ( " " , " " , " " , account , " " , offering , " " , deposit , " " , gasPrice ) if ! h . token . Check ( tkn ) { logger . Warn ( " " ) return nil , ErrAccessDenied } var acc data . Account if err := h . findByColumn ( logger , ErrAccountNotFound , & acc , " " , account ) ; err != nil { return nil , err } offer , err := h . findActiveOfferingByID ( logger , offering ) if err != nil { return nil , err } minDeposit := data . MinDeposit ( offer ) if deposit == 0 { deposit = minDeposit } else if deposit < minDeposit { logger . Error ( ErrDepositTooSmall . Error ( ) ) return nil , ErrDepositTooSmall } if err := h . pingOffering ( logger , offer ) ; err != nil { return nil , err } rid := util . NewUUID ( ) jobData := & worker . ClientPreChannelCreateData { Account : acc . ID , Offering : offering , GasPrice : gasPrice , Deposit : deposit } if err := job . AddWithData ( h . queue , nil , data . JobClientPreChannelCreate , data . JobChannel , rid , data . JobUser , jobData ) ; err != nil { logger . Error ( err . Error ( ) ) return nil , ErrInternal } return & rid , nil }
// AcceptOffering initiates JobClientPreChannelCreate job.
AcceptOffering initiates JobClientPreChannelCreate job .