func (w *Worker) ClientAfterCooperativeClose(job *data.Job) error {
	logger := w.logger.Add("method", "ClientAfterCooperativeClose",
		"job", job)

	ch, err := w.relatedChannel(logger, job,
		data.JobClientAfterCooperativeClose)
	if err != nil {
		return err
	}

	logger = logger.Add("channel", ch)

	ch.ChannelStatus = data.ChannelClosedCoop
	if err := w.saveRecord(logger, w.db.Querier, ch); err != nil {
		return err
	}

	if ch.ServiceStatus != data.ServiceTerminated {
		_, err = w.processor.TerminateChannel(ch.ID, data.JobTask, false)
		if err != nil {
			logger.Error(err.Error())
			return ErrTerminateChannel
		}
	}

	client, err := w.account(logger, ch.Client)
	if err != nil {
		return err
	}

	return w.addJob(logger, nil,
		data.JobAccountUpdateBalances, data.JobAccount, client.ID)
}
func (w *Worker) ClientAfterCooperativeClose(job *data.Job) error {
	logger := w.logger.Add("method", "ClientAfterCooperativeClose",
		"job", job)

	ch, err := w.relatedChannel(logger, job,
		data.JobClientAfterCooperativeClose)
	if err != nil {
		return err
	}

	logger = logger.Add("channel", ch)

	ch.ChannelStatus = data.ChannelClosedCoop
	if err := w.saveRecord(logger, w.db.Querier, ch); err != nil {
		return err
	}

	if ch.ServiceStatus != data.ServiceTerminated {
		_, err = w.processor.TerminateChannel(ch.ID, data.JobTask, false)
		if err != nil {
			logger.Error(err.Error())
			return ErrTerminateChannel
		}
	}

	client, err := w.account(logger, ch.Client)
	if err != nil {
		return err
	}

	return w.addJob(logger, nil,
		data.JobAccountUpdateBalances, data.JobAccount, client.ID)
}
func ( w * Worker ) ClientAfterCooperativeClose ( job * data . Job ) error { logger := w . logger . Add ( " " , " " , " " , job ) ch , err := w . relatedChannel ( logger , job , data . JobClientAfterCooperativeClose ) if err != nil { return err } logger = logger . Add ( " " , ch ) ch . ChannelStatus = data . ChannelClosedCoop if err := w . saveRecord ( logger , w . db . Querier , ch ) ; err != nil { return err } if ch . ServiceStatus != data . ServiceTerminated { _ , err = w . processor . TerminateChannel ( ch . ID , data . JobTask , false ) if err != nil { logger . Error ( err . Error ( ) ) return ErrTerminateChannel } } client , err := w . account ( logger , ch . Client ) if err != nil { return err } return w . addJob ( logger , nil , data . JobAccountUpdateBalances , data . JobAccount , client . ID ) }
// ClientAfterCooperativeClose changed channel status
// to closed cooperative and launches of terminate service procedure.
ClientAfterCooperativeClose changed channel status to closed cooperative and launches of terminate service procedure .