event

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TwoMinutes  = 60 * 2
	FiveMinutes = 60 * 5

	SixtyMinutes = 60 * 60
)
View Source
const (
	JobTypeAddSignature     = "addSignature"
	JobTypeBTCBroadcast     = "btcBroadcast"
	JobTypeBTCCheckFinality = "btcCheckFinality"
	JobTypeETHCheckfinalty  = "ethCheckFinality"
	JobTypeETHBroadcast     = "ethBroadcast"
	JobTypeETHSignRedeem    = "ethsignredeem"
	JobTypeETHVerifyRedeem  = "verifyredeem"

	MaxJobRetries = 10
)
View Source
const (
	MAX_BROADCAST_RETRY = 20
)

Variables

View Source
var (
	EthLockEngine   transition.Engine
	EthRedeemEngine transition.Engine
	BtcEngine       transition.Engine
)

Functions

func Broadcasting

func Broadcasting(ctx interface{}) error

TODO Go back to Busy broadcasting if there is a failure in Finalizing.

func Cleanup

func Cleanup(ctx interface{}) error

func DeleteCompletedJobs

func DeleteCompletedJobs(ctx *JobsContext, js *jobs.JobStore)

func Finalization

func Finalization(ctx interface{}) error

func Finalizing

func Finalizing(ctx interface{}) error

func FreezeForBroadcast

func FreezeForBroadcast(inp interface{}) error

func MakeAvailable

func MakeAvailable(input interface{}) error

func Minting

func Minting(ctx interface{}) error

func NewAddSignatureJob

func NewAddSignatureJob(trackerName, id string) jobs.Job

func NewBTCBroadcastJob

func NewBTCBroadcastJob(trackerName, id string) jobs.Job

func NewBTCCheckFinalityJob

func NewBTCCheckFinalityJob(trackerName, id string) jobs.Job

func ProcessAllJobs

func ProcessAllJobs(ctx *JobsContext, js *jobs.JobStore)

func RangeJobs

func RangeJobs(js *jobs.JobStore, pro JobProcess)

func RedeemConfirmed

func RedeemConfirmed(ctx interface{}) error

func ReportBroadcastSuccess

func ReportBroadcastSuccess(inp interface{}) error

func ReserveTracker

func ReserveTracker(inp interface{}) error

func Signing

func Signing(ctx interface{}) error

func VerifyRedeem

func VerifyRedeem(ctx interface{}) error

Types

type BTCData

type BTCData struct {
	BTCNodeAddress   string
	BTCRPCPort       string
	BTCRPCUsername   string
	BTCRPCPassword   string
	BTCChainnet      string
	BlockCypherToken string
}

type BroadcastReply

type BroadcastReply struct {
	TxHash action.Address `json:"txHash"`
	// OK indicates whether this broadcast was a request.
	// For TxSync, it indicates success of CheckTx. Does not guarantee inclusion of a block
	// For TxAsync, it always returns true
	// For TxCommit, it indicates the success of both CheckTx and DeliverTx. If the broadcast fails is false.
	OK     bool   `json:"ok"`
	Height *int64 `json:"height,omitempty"`
	Log    string `json:"log"`
}

func (*BroadcastReply) FromResultBroadcastTx

func (reply *BroadcastReply) FromResultBroadcastTx(result *ctypes.ResultBroadcastTx)

func (*BroadcastReply) FromResultBroadcastTxCommit

func (reply *BroadcastReply) FromResultBroadcastTxCommit(result *ctypes.ResultBroadcastTxCommit)

type InternalBroadcastRequest

type InternalBroadcastRequest struct {
	RawTx action.RawTx `json:"rawTx"`
}

type JobAddSignature

type JobAddSignature struct {
	Type string

	TrackerName string

	JobID string

	Status jobs.Status
}

func (*JobAddSignature) DoMyJob

func (j *JobAddSignature) DoMyJob(ctxI interface{})

func (*JobAddSignature) GetJobID

func (j *JobAddSignature) GetJobID() string

func (*JobAddSignature) GetType

func (j *JobAddSignature) GetType() string

func (JobAddSignature) IsDone

func (j JobAddSignature) IsDone() bool

type JobBTCBroadcast

type JobBTCBroadcast struct {
	Type string

	TrackerName string

	JobID string

	Status jobs.Status

	RetryCount int
}

func (*JobBTCBroadcast) DoMyJob

func (j *JobBTCBroadcast) DoMyJob(ctxI interface{})

func (*JobBTCBroadcast) GetJobID

func (j *JobBTCBroadcast) GetJobID() string

func (*JobBTCBroadcast) GetType

func (j *JobBTCBroadcast) GetType() string

simple getters

func (JobBTCBroadcast) IsDone

func (j JobBTCBroadcast) IsDone() bool

type JobBTCCheckFinality

type JobBTCCheckFinality struct {
	Type string

	TrackerName string
	JobID       string
	CheckAfter  int64

	Status jobs.Status
}

func (*JobBTCCheckFinality) DoMyJob

func (cf *JobBTCCheckFinality) DoMyJob(ctxI interface{})

func (*JobBTCCheckFinality) GetJobID

func (cf *JobBTCCheckFinality) GetJobID() string

func (*JobBTCCheckFinality) GetType

func (cf *JobBTCCheckFinality) GetType() string

func (*JobBTCCheckFinality) IsDone

func (cf *JobBTCCheckFinality) IsDone() bool

type JobBus

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

func NewJobBus

func NewJobBus(opt Option, store *jobs.JobStore) *JobBus

func (*JobBus) Close

func (j *JobBus) Close()

func (*JobBus) Start

func (j *JobBus) Start(ctx *JobsContext) error

type JobETHBroadcast

type JobETHBroadcast struct {
	TrackerName ethereum.TrackerName
	JobID       string
	RetryCount  int
	Status      jobs.Status
}

func NewETHBroadcast

func NewETHBroadcast(name ethereum.TrackerName, state ethereum2.TrackerState) *JobETHBroadcast

func (*JobETHBroadcast) DoMyJob

func (job *JobETHBroadcast) DoMyJob(ctx interface{})

func (*JobETHBroadcast) GetJobID

func (job *JobETHBroadcast) GetJobID() string

func (*JobETHBroadcast) GetType

func (job *JobETHBroadcast) GetType() string

func (*JobETHBroadcast) IsDone

func (job *JobETHBroadcast) IsDone() bool

type JobETHCheckFinality

type JobETHCheckFinality struct {
	TrackerName ethereum.TrackerName
	JobID       string
	RetryCount  int
	Status      jobs.Status
}

func (*JobETHCheckFinality) DoMyJob

func (job *JobETHCheckFinality) DoMyJob(ctx interface{})

func (*JobETHCheckFinality) GetJobID

func (job *JobETHCheckFinality) GetJobID() string

func (*JobETHCheckFinality) GetType

func (job *JobETHCheckFinality) GetType() string

func (*JobETHCheckFinality) IsDone

func (job *JobETHCheckFinality) IsDone() bool

type JobETHSignRedeem

type JobETHSignRedeem struct {
	TrackerName ethereum.TrackerName
	JobID       string
	RetryCount  int
	Status      jobs.Status
	TxHash      *ethereum.TransactionHash
}

func (*JobETHSignRedeem) DoMyJob

func (j *JobETHSignRedeem) DoMyJob(ctx interface{})

func (*JobETHSignRedeem) GetJobID

func (j *JobETHSignRedeem) GetJobID() string

func (*JobETHSignRedeem) GetType

func (j *JobETHSignRedeem) GetType() string

func (*JobETHSignRedeem) IsDone

func (j *JobETHSignRedeem) IsDone() bool

type JobETHVerifyRedeem

type JobETHVerifyRedeem struct {
	TrackerName ethereum.TrackerName
	JobID       string
	RetryCount  int
	Status      jobs.Status
}

func (*JobETHVerifyRedeem) DoMyJob

func (job *JobETHVerifyRedeem) DoMyJob(ctx interface{})

func (*JobETHVerifyRedeem) GetJobID

func (job *JobETHVerifyRedeem) GetJobID() string

func (*JobETHVerifyRedeem) GetType

func (job *JobETHVerifyRedeem) GetType() string

func (*JobETHVerifyRedeem) IsDone

func (job *JobETHVerifyRedeem) IsDone() bool

type JobProcess

type JobProcess func(job jobs.Job) jobs.Job

type JobsContext

type JobsContext struct {
	Service *Service
	Logger  *log.Logger

	Trackers   *bitcoin.TrackerStore
	Validators *identity.ValidatorStore

	BTCPrivKey *keys.PrivateKey
	ETHPrivKey *keys.PrivateKey
	BTCParams  *chaincfg.Params

	ValidatorAddress action.Address
	LockScripts      *bitcoin.LockScriptStore
	EthereumTrackers *ethereum.TrackerStore

	BTCData BTCData
	// contains filtered or unexported fields
}

func NewJobsContext

func NewJobsContext(cfg config.Server, btcChainType string, svc *Service,
	trackers *bitcoin.TrackerStore, validators *identity.ValidatorStore,
	privKey *keys.PrivateKey, ethprivKey *keys.PrivateKey,
	valAddress keys.Address, bcyToken string, lStore *bitcoin.LockScriptStore,
	btcAddress, btcRPCPort, BTCRPCUsername, BTCRPCPassword string,
	ethTracker *ethereum.TrackerStore,
) *JobsContext

func (*JobsContext) GetValidatorETHAddress

func (jc *JobsContext) GetValidatorETHAddress() common.Address

func (*JobsContext) GetValidatorETHPrivKey

func (jc *JobsContext) GetValidatorETHPrivKey() *ecdsa.PrivateKey

type Option

type Option struct {
	BtcInterval time.Duration
	EthInterval time.Duration
}

type Service

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

func NewService

func NewService(ctx node.Context, logger *log.Logger, router action.Router, tmnode *consensus.Node) *Service

func (Service) InternalBroadcast

func (svc Service) InternalBroadcast(request InternalBroadcastRequest, reply *BroadcastReply) error

Jump to

Keyboard shortcuts

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