message

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPendingChannelClosed = errors.New("pending channel was closed")

Functions

func GenerateMessageIdByNonce

func GenerateMessageIdByNonce(nonce int64) *common.Hash

Types

type MemorySequencer

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

func NewMemorySequencer

func NewMemorySequencer(client *ethclient.Client, msgStorage Storage, buffer int) *MemorySequencer

func (*MemorySequencer) Close

func (s *MemorySequencer) Close()

func (*MemorySequencer) PeekMsg

func (s *MemorySequencer) PeekMsg() (Request, error)

func (*MemorySequencer) PendingMsgCount

func (s *MemorySequencer) PendingMsgCount() (int, error)

func (*MemorySequencer) PopMsg

func (s *MemorySequencer) PopMsg() (Request, error)

func (*MemorySequencer) PushMsg

func (s *MemorySequencer) PushMsg(msg Request) error

func (*MemorySequencer) QueuedMsgCount

func (s *MemorySequencer) QueuedMsgCount() (int, error)

type MemoryStorage

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

func NewMemoryStorage

func NewMemoryStorage() (*MemoryStorage, error)

func (*MemoryStorage) AddMsg

func (s *MemoryStorage) AddMsg(req Request) error

func (*MemoryStorage) GetMsg

func (s *MemoryStorage) GetMsg(msgId common.Hash) (Message, error)

func (*MemoryStorage) HasMsg

func (s *MemoryStorage) HasMsg(msgId common.Hash) bool

func (*MemoryStorage) UpdateMsg

func (s *MemoryStorage) UpdateMsg(msg Message) error

func (*MemoryStorage) UpdateMsgStatus

func (s *MemoryStorage) UpdateMsgStatus(msgId common.Hash, status MessageStatus) error

func (*MemoryStorage) UpdateResponse

func (s *MemoryStorage) UpdateResponse(msgId common.Hash, resp Response) error

type Message

type Message struct {
	Root   *common.Hash
	Parent *common.Hash // it's created by parent if not nil
	Req    *Request
	Resp   *Response // not nil if inflight
	Status MessageStatus
}

func (*Message) Id

func (m *Message) Id() common.Hash

type MessageStatus

type MessageStatus uint8
const (
	MessageStatusSubmitted MessageStatus = iota
	MessageStatusScheduled
	MessageStatusQueued
	MessageStatusNonceAssigned
	MessageStatusInflight // Broadcasted but not on chain
	MessageStatusOnChain
	MessageStatusFinalized
	// it was broadcasted but not included on-chain until timeout, so the nonce was released
	MessageStatusNonceReleased
	MessageStatusExpired
)

type Request

type Request struct {
	From                  common.Address  // the sender of the 'transaction'
	To                    *common.Address // the destination contract (nil for contract creation)
	Value                 *big.Int        // amount of wei sent along with the call
	Gas                   uint64          // if 0, the call executes with near-infinite gas
	GasOnEstimationFailed *uint64         // how much gas you wanna provide when the msg estimation failed. As much as possible, so you can debug on-chain
	GasPrice              *big.Int        // wei <-> gas exchange ratio
	Data                  []byte          // input data, usually an ABI-encoded contract method invocation

	AccessList types.AccessList // EIP-2930 access list.

	SimulationOn bool // contains return data of msg call if true
	// ONLY available on function ScheduleMsg
	AfterMsg       *common.Hash  // message id or txHash. Used for making sure the msg was executed after it.
	StartTime      int64         // the msg was executed after the time. It's useful for one-time task.
	ExpirationTime int64         // the msg will be not included on-chain if timeout.
	Interval       time.Duration // the msg will be executed every interval.
	// contains filtered or unexported fields
}

func AssignMessageId

func AssignMessageId(msg *Request) *Request

func AssignMessageIdWithNonce

func AssignMessageIdWithNonce(msg *Request, nonce int64) *Request

func (*Request) Copy

func (q *Request) Copy() *Request

func (*Request) Id

func (m *Request) Id() common.Hash

func (*Request) SetId

func (q *Request) SetId(id common.Hash)

func (*Request) SetIdWithNonce

func (q *Request) SetIdWithNonce(nonce int64)

type Response

type Response struct {
	Id         common.Hash
	Tx         *types.Transaction
	ReturnData []byte // not nil if using SafeScheduleMsg and no err
	Err        error
}

type Sequencer

type Sequencer interface {
	PushMsg(msg Request) error
	// block if no any msgs return
	PopMsg() (Request, error)
	PeekMsg() (Request, error)
	QueuedMsgCount() (int, error)
	PendingMsgCount() (int, error)
	Close()
}

type Storage

type Storage interface {
	AddMsg(req Request) error
	HasMsg(msgId common.Hash) bool
	GetMsg(msgId common.Hash) (Message, error)
	UpdateMsg(msg Message) error
	UpdateResponse(msgId common.Hash, resp Response) error
	UpdateMsgStatus(msgId common.Hash, status MessageStatus) error
}

Jump to

Keyboard shortcuts

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