messenger

package
v0.0.0-...-7b78ed8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenesisTransaction

func GenesisTransaction() []byte

create starting block for this rollup

func HashTxs

func HashTxs(txs [][]byte) ([32]byte, error)

Types

type App

type App struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

App is the main application struct, containing all the necessary components.

func NewApp

func NewApp(cfg Config) *App

func (*App) Run

func (a *App) Run()

type Block

type Block struct {
	ParentHash [32]byte
	Hash       [32]byte
	Height     uint32
	Timestamp  time.Time
	Txs        [][]byte
}

func GenesisBlock

func GenesisBlock() Block

GenesisBlock creates the genesis block.

func NewBlock

func NewBlock(parentHash []byte, height uint32, txs [][]byte, timestamp time.Time) Block

func (*Block) ToPb

func (b *Block) ToPb() (*astriaPb.Block, error)

type Config

type Config struct {
	SequencerRPC string `env:"SEQUENCER_RPC, required"`
	ConductorRPC string `env:"CONDUCTOR_RPC, required"`
	ComposerRpc  string `env:"COMPOSER_RPC, required"`
	RESTApiPort  string `env:"RESTAPI_PORT, required"`
	RollupName   string `env:"ROLLUP_NAME, required"`
	SeqPrivate   string `env:"SEQUENCER_PRIVATE, required"`
}

type ExecutionServiceServerV1Alpha2

type ExecutionServiceServerV1Alpha2 struct {
	astriaGrpc.UnimplementedExecutionServiceServer
	// contains filtered or unexported fields
}

ExecutionServiceServerV1Alpha2 is a server that implements the ExecutionServiceServer interface.

func NewExecutionServiceServerV1Alpha2

func NewExecutionServiceServerV1Alpha2(rollupBlocks *RollupBlocks, rollupID []byte) *ExecutionServiceServerV1Alpha2

NewExecutionServiceServerV1Alpha2 creates a new ExecutionServiceServerV1Alpha2.

func (*ExecutionServiceServerV1Alpha2) BatchGetBlocks

BatchGetBlocks retrieves multiple blocks by their identifiers.

func (*ExecutionServiceServerV1Alpha2) ExecuteBlock

ExecuteBlock executes a block and adds it to the blockchain.

func (*ExecutionServiceServerV1Alpha2) GetBlock

GetBlock retrieves a block by its identifier.

func (*ExecutionServiceServerV1Alpha2) GetCommitmentState

GetCommitmentState retrieves the current commitment state of the blockchain.

func (*ExecutionServiceServerV1Alpha2) GetGenesisInfo

func (*ExecutionServiceServerV1Alpha2) UpdateCommitmentState

UpdateCommitmentState updates the commitment state of the blockchain.

type RollupBlocks

type RollupBlocks struct {
	Blocks []Block

	NewBlockChan chan Block
	// contains filtered or unexported fields
}

Messenger is a struct that manages the blocks in the blockchain.

func NewRollupBlocks

func NewRollupBlocks(newBlockChan chan Block) *RollupBlocks

func (*RollupBlocks) AddBlock

func (rb *RollupBlocks) AddBlock(block Block) error

func (*RollupBlocks) GetFirmBlock

func (rb *RollupBlocks) GetFirmBlock() *Block

func (*RollupBlocks) GetLatestBlock

func (rb *RollupBlocks) GetLatestBlock() *Block

func (*RollupBlocks) GetSingleBlock

func (rb *RollupBlocks) GetSingleBlock(height uint32) (*Block, error)

GetSingleBlock retrieves a block by its height, failing if the requested height is higher than the current height.

func (*RollupBlocks) GetSoftBlock

func (rb *RollupBlocks) GetSoftBlock() *Block

func (*RollupBlocks) Height

func (rb *RollupBlocks) Height() uint32

type SequencerClient

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

SequencerClient is a client for interacting with the sequencer.

func NewSequencerClient

func NewSequencerClient(sequencerAddr string, composerAddr string, rollupId []byte, private ed25519.PrivateKey) *SequencerClient

NewSequencerClient creates a new SequencerClient.

func (*SequencerClient) SendMessage

func (sc *SequencerClient) SendMessage(tx []byte) (*tendermintPb.ResultBroadcastTx, error)

SendMessage sends a message as a transaction.

func (*SequencerClient) SendMessageViaComposer

func (sc *SequencerClient) SendMessageViaComposer(tx []byte) error

type Transaction

type Transaction struct {
	Sender  string `json:"sender"`
	Message string `json:"message"`
}

Transaction represents a transaction in the blockchain.

type WSClient

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

func NewWSClient

func NewWSClient(conn *websocket.Conn, app *App) *WSClient

func (*WSClient) WaitForMessages

func (c *WSClient) WaitForMessages()

type WSClientList

type WSClientList map[*WSClient]bool

Jump to

Keyboard shortcuts

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