worker

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2020 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInternal errors.Error = 0x25E9<<8 + iota
	ErrInvalidJob
	ErrAccountNotFound
	ErrChannelNotFound
	ErrOfferingNotFound
	ErrUserNotFound
	ErrEndpointNotFound
	ErrTemplateNotFound
	ErrTemplateByHashNotFound
	ErrEthLogNotFound
	ErrProductNotFound
	ErrParseJobData
	ErrParsePrivateKey
	ErrParseEthAddr
	ErrParseOfferingHash
	ErrParseEthLog
	ErrWrongLogNonIndexedArgsNumber
	ErrWrongLogTopicsNumber
	ErrInsufficientPTCBalance
	ErrInsufficientPSCBalance
	ErrInsufficientEthBalance
	ErrSmallDeposit
	ErrFindApprovalBalanceData
	ErrPTCRetrieveBalance
	ErrPTCRetrieveAllowance
	ErrPTCIncreaseApproval
	ErrPSCRetrieveBalance
	ErrPSCAddBalance
	ErrPSCReturnBalance
	ErrPSCCooperativeClose
	ErrPSCRegisterOffering
	ErrPSCRemoveOffering
	ErrPSCPopUpOffering
	ErrPSCOfferingSupply
	ErrPSCCreateChannel
	ErrPSCGetChannelInfo
	ErrPSCSettle
	ErrPSCTopUpChannel
	ErrPSCUncooperativeClose
	ErrEthGetTransaction
	ErrEthTxInPendingState
	ErrEthRetrieveBalance
	ErrEthLogChannelMismatch
	ErrEthLatestBlockNumber
	ErrRecoverClientPubKey
	ErrTerminateChannel
	ErrAddJob
	ErrSignClosingMsg
	ErrNoReceiptSignature
	ErrMakeEndpointMsg
	ErrEndpointMsgSeal
	ErrGeneratePasswordHash
	ErrPublishEndpoint
	ErrPublishOffering
	ErrFetchOffering
	ErrSOMCNoOfferings
	ErrOfferNotRegistered
	ErrOfferNotCorrespondToTemplate
	ErrChannelReceiptBalance
	ErrInvalidChannelStatus
	ErrInvalidServiceStatus
	ErrOfferingNoSupply
	ErrGetEndpoint
	ErrDecryptEndpointMsg
	ErrInvalidEndpoint
	ErrFailedStopService
	ErrFailedStartService
	ErrChallengePeriodIsNotOver
	ErrWrongOfferingMsgSignature
	ErrUncompletedJobsExists
	ErrOfferingNotActive
	ErrOfferingExists
	ErrPopUpPeriodIsNotOver
	ErrOfferingDeletePeriodIsNotOver
	ErrOfferingDeposit
	ErrTorNoSet
	ErrTxNoGasIncrease
	ErrEthTxIsMined
	ErrTxNotFound
)

Errors returned by workers.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientPreChannelCreateData

type ClientPreChannelCreateData struct {
	Account  string `json:"account"`
	Offering string `json:"offering"`
	GasPrice uint64 `json:"gasPrice"`
	Deposit  uint64 `json:"deposit"`
}

ClientPreChannelCreateData is a job data for ClientPreChannelCreate.

type ClientPreChannelTopUpData

type ClientPreChannelTopUpData struct {
	Channel  string `json:"channel"`
	GasPrice uint64 `json:"gasPrice"`
}

ClientPreChannelTopUpData is a job data for ClientPreChannelTopUp.

type GasConf

type GasConf struct {
	PTC struct {
		Approve uint64
	}
	PSC struct {
		AddBalanceERC20         uint64
		RegisterServiceOffering uint64
		CreateChannel           uint64
		CooperativeClose        uint64
		ReturnBalanceERC20      uint64
		UncooperativeClose      uint64
		Settle                  uint64
		TopUp                   uint64
		PopupServiceOffering    uint64
		RemoveServiceOffering   uint64
	}
}

GasConf amounts of gas limit to use for contracts calls.

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker has all worker routines.

func NewWorker

func NewWorker(logger log.Logger, db *reform.DB, ethBack eth.Backend,
	gasConc *GasConf, pscAddr common.Address, payAddr string,
	pwdGetter data.PWDGetter, countryConf *country.Config, eptConf *ept.Config,
	torHostname string, somcClientBuilder somc.ClientBuilderInterface) (*Worker, error)

NewWorker returns new instance of worker.

func (*Worker) AccountUpdateBalances

func (w *Worker) AccountUpdateBalances(job *data.Job) error

AccountUpdateBalances updates ptc, psc and eth balance values.

func (*Worker) AfterAccountAddBalance

func (w *Worker) AfterAccountAddBalance(job *data.Job) error

AfterAccountAddBalance updates psc and ptc balance of an account.

func (*Worker) AfterAccountAddBalanceApprove added in v1.0.1

func (w *Worker) AfterAccountAddBalanceApprove(job *data.Job) error

AfterAccountAddBalanceApprove creates add balance job.

func (*Worker) AfterAccountReturnBalance

func (w *Worker) AfterAccountReturnBalance(job *data.Job) error

AfterAccountReturnBalance updates psc and ptc balance of an account.

func (*Worker) AgentAfterChannelCreate

func (w *Worker) AgentAfterChannelCreate(job *data.Job) error

AgentAfterChannelCreate registers client and creates pre service create job.

func (*Worker) AgentAfterChannelTopUp

func (w *Worker) AgentAfterChannelTopUp(job *data.Job) error

AgentAfterChannelTopUp updates deposit of a channel.

func (*Worker) AgentAfterCooperativeClose

func (w *Worker) AgentAfterCooperativeClose(job *data.Job) error

AgentAfterCooperativeClose marks channel as closed coop.

func (*Worker) AgentAfterOfferingDelete

func (w *Worker) AgentAfterOfferingDelete(job *data.Job) error

AgentAfterOfferingDelete set offering status to `remove`

func (*Worker) AgentAfterOfferingMsgBCPublish

func (w *Worker) AgentAfterOfferingMsgBCPublish(job *data.Job) error

AgentAfterOfferingMsgBCPublish updates offering status and creates somc publish job.

func (*Worker) AgentAfterOfferingPopUp

func (w *Worker) AgentAfterOfferingPopUp(job *data.Job) error

AgentAfterOfferingPopUp updates the block number when the offering was updated.

func (*Worker) AgentAfterUncooperativeClose

func (w *Worker) AgentAfterUncooperativeClose(job *data.Job) error

AgentAfterUncooperativeClose marks channel closed uncoop.

func (*Worker) AgentAfterUncooperativeCloseRequest

func (w *Worker) AgentAfterUncooperativeCloseRequest(job *data.Job) error

AgentAfterUncooperativeCloseRequest sets channel's status to challenge period.

func (*Worker) AgentPreEndpointMsgCreate

func (w *Worker) AgentPreEndpointMsgCreate(job *data.Job) error

AgentPreEndpointMsgCreate prepares endpoint message.

func (*Worker) AgentPreOfferingDelete

func (w *Worker) AgentPreOfferingDelete(job *data.Job) error

AgentPreOfferingDelete calls psc remove an offering.

func (*Worker) AgentPreOfferingMsgBCPublish

func (w *Worker) AgentPreOfferingMsgBCPublish(job *data.Job) error

AgentPreOfferingMsgBCPublish publishes offering to blockchain.

func (*Worker) AgentPreOfferingPopUp

func (w *Worker) AgentPreOfferingPopUp(job *data.Job) error

AgentPreOfferingPopUp pop ups an offering.

func (*Worker) AgentPreServiceSuspend

func (w *Worker) AgentPreServiceSuspend(job *data.Job) error

AgentPreServiceSuspend marks service as suspended.

func (*Worker) AgentPreServiceTerminate

func (w *Worker) AgentPreServiceTerminate(job *data.Job) error

AgentPreServiceTerminate terminates the service.

func (*Worker) AgentPreServiceUnsuspend

func (w *Worker) AgentPreServiceUnsuspend(job *data.Job) error

AgentPreServiceUnsuspend marks service as active.

func (*Worker) ClientAfterChannelCreate

func (w *Worker) ClientAfterChannelCreate(job *data.Job) error

ClientAfterChannelCreate activates channel and triggers endpoint retrieval.

func (*Worker) ClientAfterChannelTopUp

func (w *Worker) ClientAfterChannelTopUp(job *data.Job) error

ClientAfterChannelTopUp updates deposit of a channel.

func (*Worker) ClientAfterCooperativeClose

func (w *Worker) ClientAfterCooperativeClose(job *data.Job) error

ClientAfterCooperativeClose changed channel status to closed cooperative and launches of terminate service procedure.

func (*Worker) ClientAfterOfferingDelete

func (w *Worker) ClientAfterOfferingDelete(job *data.Job) error

ClientAfterOfferingDelete sets offer status to `remove`;

func (*Worker) ClientAfterOfferingMsgBCPublish

func (w *Worker) ClientAfterOfferingMsgBCPublish(job *data.Job) error

ClientAfterOfferingMsgBCPublish creates offering.

func (*Worker) ClientAfterOfferingPopUp

func (w *Worker) ClientAfterOfferingPopUp(job *data.Job) error

ClientAfterOfferingPopUp updates offering in db or retrieves from somc if new.

func (*Worker) ClientAfterUncooperativeClose

func (w *Worker) ClientAfterUncooperativeClose(job *data.Job) error

ClientAfterUncooperativeClose changed channel status to closed uncooperative.

func (*Worker) ClientAfterUncooperativeCloseRequest

func (w *Worker) ClientAfterUncooperativeCloseRequest(job *data.Job) error

ClientAfterUncooperativeCloseRequest waits for the channel to uncooperative close, starts the service termination process.

func (*Worker) ClientEndpointGet added in v0.22.0

func (w *Worker) ClientEndpointGet(job *data.Job) error

ClientEndpointGet decodes endpoint message, saves it in the DB and triggers product configuration.

func (*Worker) ClientPreChannelCreate

func (w *Worker) ClientPreChannelCreate(job *data.Job) error

ClientPreChannelCreate triggers a channel creation.

func (*Worker) ClientPreChannelTopUp

func (w *Worker) ClientPreChannelTopUp(job *data.Job) error

ClientPreChannelTopUp checks client balance and creates transaction for increase the channel deposit.

func (*Worker) ClientPreServiceSuspend

func (w *Worker) ClientPreServiceSuspend(job *data.Job) error

ClientPreServiceSuspend suspends service.

func (*Worker) ClientPreServiceTerminate

func (w *Worker) ClientPreServiceTerminate(job *data.Job) error

ClientPreServiceTerminate terminates service.

func (*Worker) ClientPreServiceUnsuspend

func (w *Worker) ClientPreServiceUnsuspend(job *data.Job) error

ClientPreServiceUnsuspend activates service.

func (*Worker) ClientPreUncooperativeClose

func (w *Worker) ClientPreUncooperativeClose(job *data.Job) error

ClientPreUncooperativeClose waits for the challenge period then deletes the channel and settles by transferring the balance to the Agent and the rest of the deposit back to the Client.

func (*Worker) ClientPreUncooperativeCloseRequest

func (w *Worker) ClientPreUncooperativeCloseRequest(job *data.Job) error

ClientPreUncooperativeCloseRequest requests the closing of the channel and starts the challenge period.

func (*Worker) ClientRecordClosing added in v1.0.0

func (w *Worker) ClientRecordClosing(job *data.Job) error

ClientRecordClosing records new closing and schedules rating recalculation if specified.

func (*Worker) CompleteServiceTransition added in v0.23.0

func (w *Worker) CompleteServiceTransition(job *data.Job) error

CompleteServiceTransition is an end step of service status transitioning.

func (*Worker) DecrementCurrentSupply

func (w *Worker) DecrementCurrentSupply(job *data.Job) error

DecrementCurrentSupply finds offering and decrements its current supply.

func (*Worker) IncreaseTxGasPrice added in v1.2.0

func (w *Worker) IncreaseTxGasPrice(job *data.Job) error

IncreaseTxGasPrice resent related_id tranaction with increased gas price.

func (*Worker) IncrementCurrentSupply

func (w *Worker) IncrementCurrentSupply(job *data.Job) error

IncrementCurrentSupply finds offering and increments its current supply.

func (*Worker) PreAccountAddBalance

func (w *Worker) PreAccountAddBalance(job *data.Job) error

PreAccountAddBalance adds balance to psc.

func (*Worker) PreAccountAddBalanceApprove

func (w *Worker) PreAccountAddBalanceApprove(job *data.Job) error

PreAccountAddBalanceApprove approve balance if amount exists.

func (*Worker) PreAccountReturnBalance

func (w *Worker) PreAccountReturnBalance(job *data.Job) error

PreAccountReturnBalance returns from psc to ptc.

func (*Worker) SetProcessor

func (w *Worker) SetProcessor(processor *proc.Processor)

SetProcessor sets a processor.

func (*Worker) SetQueue

func (w *Worker) SetQueue(queue job.Queue)

SetQueue sets a queue for handlers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL