router

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CodeConnectionError = iota + 100
	CodeServerError
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GetAddressFn

type GetAddressFn func(
	ctx context.Context,
	request *namespacetypes.AddressRequest,
) (*namespacetypes.AddressResponse, error)

type GetQueryCtxFn

type GetQueryCtxFn func(height int64, prove bool) (sdk.Context, error)

type Option

type Option func(r *routerImpl)

func WithCredentials

func WithCredentials(credPath string) Option

WithCredentials sets the SSH credentials for the gRPC server.

type Result

type Result struct {
	*routerv1.SendMessageResponse
	// contains filtered or unexported fields
}

type ResultStorage

type ResultStorage interface {
	Result(key string) (Result, bool)
	SetResult(msg *routerv1.SendMessageResponse)
}

func NewMemoryResultStorage

func NewMemoryResultStorage(keepAlive time.Duration) ResultStorage

type Router

type Router interface {
	// SendMessage queues a message to be sent to a game shard.
	SendMessage(_ context.Context, namespace string, sender string, msgID string, msg []byte) error
	// Query queries a game shard.
	Query(ctx context.Context, request []byte, resource, namespace string) ([]byte, error)
	// MessageResult gets the game shard transaction Result that originated from an EVM tx.
	MessageResult(_ context.Context, evmTxHash string) ([]byte, string, uint32, error)
	// PostBlockHook implements the polaris EVM PostBlock hook. It runs after an EVM tx execution has finished
	// processing.
	PostBlockHook(types.Transactions, types.Receipts, types.Signer)
}

Router defines the methods required to interact with a game shard. The methods are invoked from EVM smart contracts.

func NewRouter

func NewRouter(logger log.Logger, ctxGetter GetQueryCtxFn, addrGetter GetAddressFn, opts ...Option) Router

NewRouter returns a Router.

Jump to

Keyboard shortcuts

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