types

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MonitoredTxStatusCreated mean the tx was just added to the storage
	MonitoredTxStatusCreated = MonitoredTxStatus("created")

	// MonitoredTxStatusFailed means the tx was already mined and failed with an
	// error that can't be recovered automatically, ex: the data in the tx is invalid
	// and the tx gets reverted
	MonitoredTxStatusFailed = MonitoredTxStatus("failed")

	// MonitoredTxStatusConfirmed means the tx was already mined and the receipt
	// status is Successful
	MonitoredTxStatusConfirmed = MonitoredTxStatus("confirmed")

	MonitoredTxStatusCompressing = MonitoredTxStatus("compressing")

	MonitoredTxStatusClaiming = MonitoredTxStatus("claimiming")
)
View Source
const (
	// MonitoredTxStatusCreated means compress txs data but no send any claim yet
	MonitoredTxGroupStatusCreated = MonitoredTxGroupStatus("created")

	// MonitoredTxGroupStatusClaiming means it have send a claim tx and is waiting for response
	MonitoredTxGroupStatusClaiming = MonitoredTxGroupStatus("claiming")

	// MonitoredTxGroupStatussFailed reach maximum retries and failed
	MonitoredTxGroupStatussFailed = MonitoredTxGroupStatus("failed")

	// MonitoredTxStatusConfirmed means the tx was already mined and the receipt status is Successful
	MonitoredTxGroupStatusConfirmed = MonitoredTxGroupStatus("confirmed")
)
View Source
const (
	ReceiptStatusFailed     = 0
	ReceiptStatusSuccessful = 1
	ReceiptStatusOutdated   = 2
)

Variables

View Source
var (
	// ErrAlreadyExists when the object already exists
	ErrAlreadyExists = errors.New("already exists")
)

Functions

This section is empty.

Types

type MonitoredTx

type MonitoredTx struct {
	// DepositID is the tx identifier controller by the caller
	DepositID uint64

	// From is a sender of the tx, used to identify which private key should be used to sing the tx
	From common.Address

	// To is a receiver of the tx
	To *common.Address

	// Nonce used to create the tx
	Nonce uint64

	// Value is a tx value
	Value *big.Int

	// Data is a tx data
	Data []byte

	// Gas is a tx gas
	Gas uint64

	// GasPrice is the tx gas price
	GasPrice *big.Int

	// Status of this monitoring
	Status MonitoredTxStatus

	// History represent all transaction hashes from
	// transactions created using this struct data and
	// sent to the network
	History map[common.Hash]bool

	// CreatedAt date time it was created
	CreatedAt time.Time

	// UpdatedAt last date time it was updated
	UpdatedAt time.Time

	// GroupID is the group id of the tx if have it (could be null)
	GroupID *uint64

	// GlobalExitRoot is the ger used to get the merkle proof
	GlobalExitRoot common.Hash
}

MonitoredTx represents a set of information used to build tx plus information to monitor if the transactions was sent successfully

func (MonitoredTx) AddHistory

func (mTx MonitoredTx) AddHistory(tx *types.Transaction) error

AddHistory adds a transaction to the monitoring history

func (*MonitoredTx) HistoryHashSlice

func (mTx *MonitoredTx) HistoryHashSlice() [][]byte

HistoryHashSlice returns the current history field as a string slice

func (*MonitoredTx) IsCandidateToBeGrouped added in v0.5.0

func (mTx *MonitoredTx) IsCandidateToBeGrouped(ger common.Hash) bool

IsCandidateForGroup returns true if the tx is a candidate to be grouped

func (MonitoredTx) RemoveHistory

func (mTx MonitoredTx) RemoveHistory(tx *types.Transaction)

RemoveHistory removes a transaction from the monitoring history

func (MonitoredTx) Tx

func (mTx MonitoredTx) Tx() *types.Transaction

Tx uses the current information to build a tx

type MonitoredTxGroup added in v0.5.0

type MonitoredTxGroup struct {
	DbEntry MonitoredTxGroupDBEntry
	Txs     []MonitoredTx
}

func NewMonitoredTxGroup added in v0.5.0

func NewMonitoredTxGroup(entry MonitoredTxGroupDBEntry, txs []MonitoredTx) MonitoredTxGroup

func (*MonitoredTxGroup) AddTx added in v0.5.0

func (m *MonitoredTxGroup) AddTx(tx MonitoredTx)

func (*MonitoredTxGroup) AssignTxsGroupID added in v0.5.0

func (m *MonitoredTxGroup) AssignTxsGroupID()

func (MonitoredTxGroup) GetTxByDepositID added in v0.5.0

func (m MonitoredTxGroup) GetTxByDepositID(depositID uint64) *MonitoredTx

func (MonitoredTxGroup) GetTxsDepositID added in v0.5.0

func (m MonitoredTxGroup) GetTxsDepositID() []uint64

func (MonitoredTxGroup) GetTxsDepositIDString added in v0.5.0

func (m MonitoredTxGroup) GetTxsDepositIDString() string

type MonitoredTxGroupDBEntry added in v0.5.0

type MonitoredTxGroupDBEntry struct {
	// GroupID is the group id of the tx if have it (could be null)
	GroupID uint64

	Status MonitoredTxGroupStatus

	DepositIDs []uint64

	// Result of compressing all claimAsset and claimMessage txs of the group
	CompressedTxData []byte

	ClaimTxHistory *TxHistoryV2
	// CreatedAt date time it was created
	CreatedAt time.Time

	// UpdatedAt last date time it was updated
	UpdatedAt time.Time

	NumRetries int32
	// LastLog is a textual status of the last action that taken and it's relevant
	LastLog string
}

func (*MonitoredTxGroupDBEntry) AddPendingTx added in v0.5.0

func (m *MonitoredTxGroupDBEntry) AddPendingTx(txHash common.Hash) uint64

func (*MonitoredTxGroupDBEntry) IsClaimTxHistoryEmpty added in v0.5.0

func (m *MonitoredTxGroupDBEntry) IsClaimTxHistoryEmpty() bool

type MonitoredTxGroupStatus added in v0.5.0

type MonitoredTxGroupStatus string

MonitoredTxGroupStatus represents the status of a monitored tx

func (MonitoredTxGroupStatus) String added in v0.5.0

func (s MonitoredTxGroupStatus) String() string

String returns a string representation of the status

type MonitoredTxStatus

type MonitoredTxStatus string

MonitoredTxStatus represents the status of a monitored tx

func (MonitoredTxStatus) String

func (s MonitoredTxStatus) String() string

String returns a string representation of the status

type TxHashHistoryEntry added in v0.5.0

type TxHashHistoryEntry struct {
	TxHash common.Hash
	// null, ReceiptStatusFailed or ReceiptStatusSuccessful
	ReceiptStatus *uint64
	// CreatedAt date time it was created
	CreatedAt time.Time
}

func (*TxHashHistoryEntry) IsExhaustedTimeWaitingForReceipt added in v0.5.0

func (t *TxHashHistoryEntry) IsExhaustedTimeWaitingForReceipt(now time.Time, maxTime time.Duration) bool

func (*TxHashHistoryEntry) IsFailed added in v0.5.0

func (t *TxHashHistoryEntry) IsFailed() bool

func (*TxHashHistoryEntry) IsOutdated added in v0.5.0

func (t *TxHashHistoryEntry) IsOutdated() bool

func (*TxHashHistoryEntry) IsPending added in v0.5.0

func (t *TxHashHistoryEntry) IsPending() bool

func (*TxHashHistoryEntry) IsSuccessful added in v0.5.0

func (t *TxHashHistoryEntry) IsSuccessful() bool

func (*TxHashHistoryEntry) Outdate added in v0.5.0

func (t *TxHashHistoryEntry) Outdate()

func (*TxHashHistoryEntry) ReceiptFailed added in v0.5.0

func (t *TxHashHistoryEntry) ReceiptFailed()

func (*TxHashHistoryEntry) ReceiptSuccessful added in v0.5.0

func (t *TxHashHistoryEntry) ReceiptSuccessful()

type TxHistoryV2 added in v0.5.0

type TxHistoryV2 struct {
	Version  uint64
	TxHashes []TxHashHistoryEntry
}

func NewTxHistoryV2FromJson added in v0.5.0

func NewTxHistoryV2FromJson(jsonStr string) (*TxHistoryV2, error)

func (*TxHistoryV2) AddPendingTx added in v0.5.0

func (t *TxHistoryV2) AddPendingTx(txHash common.Hash)

func (*TxHistoryV2) GetMoreRecentTx added in v0.5.0

func (t *TxHistoryV2) GetMoreRecentTx() *TxHashHistoryEntry

func (*TxHistoryV2) ToJson added in v0.5.0

func (t *TxHistoryV2) ToJson() (string, error)

type TxMonitorer added in v0.5.0

type TxMonitorer interface {
	MonitorTxs(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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