func (w *Worker) AgentPreOfferingPopUp(job *data.Job) error {
	logger := w.logger.Add("method", "AgentPreOfferingPopUp", "job", job)
	offering, err := w.relatedOffering(logger,
		job, data.JobAgentPreOfferingPopUp)
	if err != nil {
		return err
	}

	logger = logger.Add("offering", offering.ID)

	if offering.Status != data.OfferRegistered &&
		offering.Status != data.OfferPoppedUp {
		return ErrOfferNotRegistered
	}

	jobDate, err := w.publishData(logger, job)
	if err != nil {
		return err
	}

	offeringHash, err := data.HexToHash(offering.Hash)
	if err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	err = w.agentOfferingPopUpFindRelatedJobs(logger, offering.ID, job.ID)
	if err != nil {
		return err
	}

	err = w.checkInPeriod(logger, offeringHash, data.SettingsPeriodPopUp,
		ErrPopUpPeriodIsNotOver)
	if err != nil {
		return err
	}

	key, err := w.accountKey(logger, offering.Agent)
	if err != nil {
		return err
	}

	auth := bind.NewKeyedTransactor(key)
	auth.GasLimit = w.gasConf.PSC.PopupServiceOffering
	auth.GasPrice = new(big.Int).SetUint64(jobDate.GasPrice)

	tx, err := w.ethBack.PSCPopupServiceOffering(auth, offeringHash,
		offering.SOMCType, offering.SOMCData)
	if err != nil {
		logger.Add("GasLimit", auth.GasLimit,
			"GasPrice", auth.GasPrice).Error(err.Error())
		return ErrPSCPopUpOffering
	}

	offering.Status = data.OfferPoppingUp
	if err := w.saveRecord(logger, w.db.Querier, offering); err != nil {
		return err
	}

	return w.saveEthTX(logger, job, tx, "PopupServiceOffering",
		job.RelatedType, job.RelatedID, offering.Agent,
		data.HexFromBytes(w.pscAddr.Bytes()))
}
func (w *Worker) AgentPreOfferingPopUp(job *data.Job) error {
	logger := w.logger.Add("method", "AgentPreOfferingPopUp", "job", job)
	offering, err := w.relatedOffering(logger,
		job, data.JobAgentPreOfferingPopUp)
	if err != nil {
		return err
	}

	logger = logger.Add("offering", offering.ID)

	if offering.Status != data.OfferRegistered &&
		offering.Status != data.OfferPoppedUp {
		return ErrOfferNotRegistered
	}

	jobDate, err := w.publishData(logger, job)
	if err != nil {
		return err
	}

	offeringHash, err := data.HexToHash(offering.Hash)
	if err != nil {
		logger.Error(err.Error())
		return ErrInternal
	}

	err = w.agentOfferingPopUpFindRelatedJobs(logger, offering.ID, job.ID)
	if err != nil {
		return err
	}

	err = w.checkInPeriod(logger, offeringHash, data.SettingsPeriodPopUp,
		ErrPopUpPeriodIsNotOver)
	if err != nil {
		return err
	}

	key, err := w.accountKey(logger, offering.Agent)
	if err != nil {
		return err
	}

	auth := bind.NewKeyedTransactor(key)
	auth.GasLimit = w.gasConf.PSC.PopupServiceOffering
	auth.GasPrice = new(big.Int).SetUint64(jobDate.GasPrice)

	tx, err := w.ethBack.PSCPopupServiceOffering(auth, offeringHash,
		offering.SOMCType, offering.SOMCData)
	if err != nil {
		logger.Add("GasLimit", auth.GasLimit,
			"GasPrice", auth.GasPrice).Error(err.Error())
		return ErrPSCPopUpOffering
	}

	offering.Status = data.OfferPoppingUp
	if err := w.saveRecord(logger, w.db.Querier, offering); err != nil {
		return err
	}

	return w.saveEthTX(logger, job, tx, "PopupServiceOffering",
		job.RelatedType, job.RelatedID, offering.Agent,
		data.HexFromBytes(w.pscAddr.Bytes()))
}
// AgentPreOfferingPopUp pop ups an offering.