message

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: GPL-3.0 Imports: 18 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 Broadcaster added in v0.1.0

type Broadcaster interface {
	CallAndSendMsg(ctx context.Context, msg Request) (resp Response)
	SendMsg(ctx context.Context, msg Request) (resp Response)
}

type Manager added in v0.1.0

type Manager interface {
	Storage
	ScheduleManager
}

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) GetNonce added in v0.1.0

func (s *MemoryStorage) GetNonce(msgId common.Hash) (nonce uint64, err 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) UpdateReceipt added in v0.1.0

func (s *MemoryStorage) UpdateReceipt(msgId common.Hash, receipt Receipt) 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
	Receipt *Receipt  // not nil if on-chain
	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 Receipt added in v0.1.0

type Receipt struct {
	Id        common.Hash
	TxReceipt *types.Receipt
}

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) CopyWithoutId added in v0.1.0

func (q *Request) CopyWithoutId() *Request

func (*Request) Id

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

func (*Request) SetId

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

func (*Request) SetIdWithNonce

func (q *Request) SetIdWithNonce(nonce int64) *Request

func (*Request) SetRandomId added in v0.1.0

func (q *Request) SetRandomId() *Request

type Response

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

type ScheduleManager added in v0.1.0

type ScheduleManager interface {
	CallAndSendMsg(ctx context.Context, msg Request) (resp Response)
	CallMsg(ctx context.Context, msg Request, blockNumber *big.Int) (resp Response)

	SendMsg(ctx context.Context, msg Request) (resp Response)
	ReplaceMsgWithHigherGasPrice(ctx context.Context, msgId common.Hash) (resp Response)

	NewTransaction(ctx context.Context, msg Request) (*types.Transaction, error)
	MessageToTransactOpts(ctx context.Context, msg Request) (*bind.TransactOpts, error)

	WaitTxReceipt(txHash common.Hash, confirmations uint64, timeout time.Duration) (*types.Receipt, bool)
	WaitMsgResponse(msgId common.Hash, timeout time.Duration) (*Response, bool)
	WaitMsgReceipt(msgId common.Hash, confirmations uint64, timeout time.Duration) (*Receipt, bool)
}

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 SimpleBroadcaster added in v0.1.0

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

SimpleBroadcaster makes sure that every message broadcasted could be consumed(on-chain) correctly.

func NewSimpleBroadcaster added in v0.1.0

func NewSimpleBroadcaster(msgManager Manager) *SimpleBroadcaster

func (SimpleBroadcaster) CallAndSendMsg added in v0.1.0

func (b SimpleBroadcaster) CallAndSendMsg(ctx context.Context, msg Request) (resp Response)

func (SimpleBroadcaster) SendMsg added in v0.1.0

func (b SimpleBroadcaster) SendMsg(ctx context.Context, msg Request) (resp Response)

type SimpleManager added in v0.1.0

type SimpleManager struct {
	account.Registry
	Storage
	// contains filtered or unexported fields
}

func NewSimpleManager added in v0.1.0

func NewSimpleManager(backend ethBackend, nm nonce.Manager, accountRegistry account.Registry, storage Storage) *SimpleManager

func (*SimpleManager) CallAndSendMsg added in v0.1.0

func (c *SimpleManager) CallAndSendMsg(ctx context.Context, msg Request) (resp Response)

func (*SimpleManager) CallMsg added in v0.1.0

func (c *SimpleManager) CallMsg(ctx context.Context, msg Request, blockNumber *big.Int) (resp Response)

func (SimpleManager) MessageToTransactOpts added in v0.1.0

func (c SimpleManager) MessageToTransactOpts(ctx context.Context, msg Request) (*bind.TransactOpts, error)

func (SimpleManager) NewTransaction added in v0.1.0

func (c SimpleManager) NewTransaction(ctx context.Context, msg Request) (*types.Transaction, error)

func (SimpleManager) ReplaceMsgWithHigherGasPrice added in v0.1.0

func (m SimpleManager) ReplaceMsgWithHigherGasPrice(ctx context.Context, msgId common.Hash) (resp Response)

func (SimpleManager) SendMsg added in v0.1.0

func (m SimpleManager) SendMsg(ctx context.Context, msg Request) (resp Response)

func (SimpleManager) WaitMsgReceipt added in v0.1.0

func (c SimpleManager) WaitMsgReceipt(msgId common.Hash, confirmations uint64, timeout time.Duration) (*Receipt, bool)

func (SimpleManager) WaitMsgResponse added in v0.1.0

func (c SimpleManager) WaitMsgResponse(msgId common.Hash, timeout time.Duration) (*Response, bool)

func (SimpleManager) WaitTxReceipt added in v0.1.0

func (c SimpleManager) WaitTxReceipt(txHash common.Hash, confirmations uint64, timeout time.Duration) (*types.Receipt, bool)

type Storage

type Storage interface {
	StorageReader
	StorageWriter
}

type StorageReader added in v0.1.0

type StorageReader interface {
	HasMsg(msgId common.Hash) bool
	GetMsg(msgId common.Hash) (Message, error)
	GetNonce(msgId common.Hash) (uint64, error)
}

type StorageWriter added in v0.1.0

type StorageWriter interface {
	AddMsg(req Request) error
	UpdateMsg(msg Message) error
	UpdateResponse(msgId common.Hash, resp Response) error
	UpdateReceipt(msgId common.Hash, receipt Receipt) 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