worker

package
v0.0.0-...-cb3ca1d Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2019 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidJob = errors.New("unexpected job type or job related type")
)

Errors returned by workers.

Functions

This section is empty.

Types

type EthBackend

type EthBackend interface {
	CooperativeClose(*bind.TransactOpts, common.Address, uint32,
		[common.HashLength]byte, *big.Int, []byte, []byte) (*types.Transaction, error)

	GetTransactionByHash(context.Context, common.Hash) (*types.Transaction, bool, error)

	RegisterServiceOffering(*bind.TransactOpts, [common.HashLength]byte,
		*big.Int, uint16) (*types.Transaction, error)

	PTCBalanceOf(*bind.CallOpts, common.Address) (*big.Int, error)

	PTCIncreaseApproval(*bind.TransactOpts, common.Address, *big.Int) (*types.Transaction, error)

	PSCBalanceOf(*bind.CallOpts, common.Address) (*big.Int, error)

	PSCAddBalanceERC20(*bind.TransactOpts, *big.Int) (*types.Transaction, error)

	PSCReturnBalanceERC20(*bind.TransactOpts, *big.Int) (*types.Transaction, error)

	EthBalanceAt(context.Context, common.Address) (*big.Int, error)
}

EthBackend adapter to communicate with contract.

func NewEthBackend

NewEthBackend returns eth back implementation.

type GasConf

type GasConf struct {
	PTC struct {
		Approve uint64
	}
	PSC struct {
		AddBalanceERC20                uint64
		RegisterServiceOffering        uint64
		CreateChannel                  uint64
		CooperativeClose               uint64
		ReturnBalanceERC20             uint64
		SetNetworkFee                  uint64
		UncooperativeClose             uint64
		Settle                         uint64
		TopUp                          uint64
		GetChannelInfo                 uint64
		PublishServiceOfferingEndpoint uint64
		GetKey                         uint64
		BalanceOf                      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(db *reform.DB, somc *somc.Conn,
	ethBack EthBackend, gasConc *GasConf,
	pscAddr common.Address,
	payAddr string, pwdGetter data.PWDGetter,
	decryptKeyFunc data.ToPrivateKeyFunc) (*Worker, error)

NewWorker returns new instance of worker.

func (*Worker) AccountAddCheckBalance

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

AccountAddCheckBalance 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) 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) AgentAfterEndpointMsgSOMCPublish

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

AgentAfterEndpointMsgSOMCPublish suspends service if some pre payment expected.

func (*Worker) AgentAfterOfferingMsgBCPublish

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

AgentAfterOfferingMsgBCPublish updates offering status and creates somc publish job.

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) AgentPreCooperativeClose

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

AgentPreCooperativeClose call contract cooperative close method and trigger service terminate job.

func (*Worker) AgentPreEndpointMsgCreate

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

AgentPreEndpointMsgCreate prepares endpoint message to be sent to client.

func (*Worker) AgentPreEndpointMsgSOMCPublish

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

AgentPreEndpointMsgSOMCPublish sends msg to somc and creates after job.

func (*Worker) AgentPreOfferingMsgBCPublish

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

AgentPreOfferingMsgBCPublish publishes offering to blockchain.

func (*Worker) AgentPreOfferingMsgSOMCPublish

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

AgentPreOfferingMsgSOMCPublish publishes to somc and creates after job.

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 marks service as active.

func (*Worker) AgentPreServiceUnsuspend

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

AgentPreServiceUnsuspend marks service as active.

func (*Worker) ClientPreChannelCreate

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

ClientPreChannelCreate creates channel.

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) SetQueue

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

SetQueue sets queue for handlers.

Jump to

Keyboard shortcuts

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