router

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeSuccess = uint32(iota)
	CodeTxFailed
	CodeNoResult
	CodeServerUnresponsive
	CodeUnauthorized
	CodeUnsupportedMessage
	CodeInvalidFormat
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	GetMessageByFullName(string) (types.Message, bool)
	GetMessageByID(id types.MessageID) (types.Message, bool)
	HandleEVMQuery(name string, abiRequest []byte) ([]byte, error)
	GetSignerComponentForPersona(string) (*component.SignerComponent, error)
	WaitForNextTick() bool

	AddEVMTransaction(id types.MessageID, msgValue any, tx *sign.Transaction, evmTxHash string) (
		tick uint64, txHash types.TxHash,
	)
	ConsumeEVMMsgResult(evmTxHash string) ([]byte, []error, string, bool)
}

Provider provides the Router with the necessary functionality to handle API requests from the EVM. The ecs.Engine is expected to implement these methods.

type Router

type Router interface {
	// RegisterGameShard registers this game shard to the base shard. This is ONLY needed so that the base shard can
	// route requests from the EVM to this game shard by using its namespace.
	RegisterGameShard(context.Context) error

	// SubmitTxBlob submits transactions processed in a tick to the base shard.
	SubmitTxBlob(
		ctx context.Context,
		processedTxs txpool.TxMap,
		epoch,
		unixTimestamp uint64,
	) error

	TransactionIterator() iterator.Iterator

	// Shutdown gracefully stops the EVM gRPC handler.
	Shutdown()
	// Start serves the EVM gRPC server.
	Start() error
}

Router provides functionality for Cardinal to interact with the EVM Base Shard. This involves a few responsibilities:

  • Registering itself to the base shard.
  • Receiving API requests from EVM smart contracts on the base shard.
  • Sending transactions to the base shard's game sequencer.
  • Querying transactions from the base shard to rebuild game state.

func New

func New(namespace, sequencerAddr, routerKey string, provider Provider) (Router, error)

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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