proc/worker/agent.go
func (w *Worker) AgentPreOfferingDelete(job *data.Job) error {
	logger := w.logger.Add("method", "AgentPreOfferingDelete", "job", job)

	offering, err := w.relatedOffering(logger,
		job, data.JobAgentPreOfferingDelete)
	if err != nil {
		return err
	}

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

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

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

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

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

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

	tx, err := w.ethBack.PSCRemoveServiceOffering(auth, offeringHash)
	if err != nil {
		logger.Add("GasLimit", auth.GasLimit,
			"GasPrice", auth.GasPrice).Error(err.Error())
		return ErrPSCRemoveOffering
	}

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

	return w.saveEthTX(logger, job, tx, "RemoveServiceOffering",
		job.RelatedType, job.RelatedID, offering.Agent,
		data.HexFromBytes(w.pscAddr.Bytes()))
}
func (w *Worker) AgentPreOfferingDelete(job *data.Job) error {
	logger := w.logger.Add("method", "AgentPreOfferingDelete", "job", job)

	offering, err := w.relatedOffering(logger,
		job, data.JobAgentPreOfferingDelete)
	if err != nil {
		return err
	}

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

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

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

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

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

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

	tx, err := w.ethBack.PSCRemoveServiceOffering(auth, offeringHash)
	if err != nil {
		logger.Add("GasLimit", auth.GasLimit,
			"GasPrice", auth.GasPrice).Error(err.Error())
		return ErrPSCRemoveOffering
	}

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

	return w.saveEthTX(logger, job, tx, "RemoveServiceOffering",
		job.RelatedType, job.RelatedID, offering.Agent,
		data.HexFromBytes(w.pscAddr.Bytes()))
}
func ( w * Worker ) AgentPreOfferingDelete ( job * data . Job ) error { logger := w . logger . Add ( " " , " " , " " , job ) offering , err := w . relatedOffering ( logger , job , data . JobAgentPreOfferingDelete ) if err != nil { return err } if offering . Status != data . OfferRegistered && offering . Status != data . OfferPoppedUp { return ErrOfferNotRegistered } jobDate , err := w . publishData ( logger , job ) if err != nil { return err } key , err := w . accountKey ( logger , offering . Agent ) if err != nil { return err } offeringHash , err := data . HexToHash ( offering . Hash ) if err != nil { logger . Error ( err . Error ( ) ) return err } err = w . checkInPeriod ( logger , offeringHash , data . SettingsPeriodRemove , ErrOfferingDeletePeriodIsNotOver ) if err != nil { return err } auth := bind . NewKeyedTransactor ( key ) auth . GasLimit = w . gasConf . PSC . RemoveServiceOffering auth . GasPrice = new ( big . Int ) . SetUint64 ( jobDate . GasPrice ) tx , err := w . ethBack . PSCRemoveServiceOffering ( auth , offeringHash ) if err != nil { logger . Add ( " " , auth . GasLimit , " " , auth . GasPrice ) . Error ( err . Error ( ) ) return ErrPSCRemoveOffering } offering . Status = data . OfferRemoving if err := w . saveRecord ( logger , w . db . Querier , offering ) ; err != nil { return err } return w . saveEthTX ( logger , job , tx , " " , job . RelatedType , job . RelatedID , offering . Agent , data . HexFromBytes ( w . pscAddr . Bytes ( ) ) ) }
// AgentPreOfferingDelete calls psc remove an offering.
AgentPreOfferingDelete calls psc remove an offering .