sequencer

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Name = "shard_sequencer"
)

Functions

This section is empty.

Types

type Option

type Option func(*Sequencer)

func WithCredentials

func WithCredentials(certPath, keyPath string) Option

type Sequencer

type Sequencer struct {
	shard.UnimplementedTransactionHandlerServer
	// contains filtered or unexported fields
}

Sequencer handles sequencing game shard transactions.

func NewShardSequencer

func NewShardSequencer(opts ...Option) *Sequencer

NewShardSequencer returns a new game shardsequencer server. It runs on a default port of 9601, unless the SHARD_SEQUENCER_PORT environment variable is set.

The sequencer exposes a single gRPC endpoint, SubmitShardTx, which will take in transactions from game shards, indexed by namespace. At every block, the sequencer tx queue is flushed, and processed in the storage shard storage module, persisting the data to the blockchain.

func (*Sequencer) FlushMessages

func (s *Sequencer) FlushMessages() []*types.SubmitShardTxRequest

FlushMessages empties and returns all messages stored in the queue.

func (*Sequencer) Serve

func (s *Sequencer) Serve()

Serve serves the server in a new go routine.

func (*Sequencer) Submit

Submit appends the game shard tx submission to the tx queue.

type TxQueue

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

TxQueue acts as a transaction queue. Transactions come in to the TxQueue with an epoch.

func NewTxQueue

func NewTxQueue(moduleAddr string) *TxQueue

func (*TxQueue) AddTx

func (tc *TxQueue) AddTx(namespace string, epoch, unixTimestamp, txID uint64, payload []byte)

AddTx adds a transaction to the queue.

func (*TxQueue) GetTxs

func (tc *TxQueue) GetTxs() []*types.SubmitShardTxRequest

GetTxs gets all currently queued transactions sorted by namespace and by transaction ID, and then clears the queue.

Jump to

Keyboard shortcuts

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