core

package
v0.0.0-...-4e9d6c2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartTestNode

func StartTestNode(t *testing.T) testnode.Context

StartTestNode simply starts Tendermint and Elysium App tandem with default testing configuration.

func StartTestNodeWithConfig

func StartTestNodeWithConfig(t *testing.T, cfg *TestConfig) testnode.Context

StartTestNodeWithConfig starts Tendermint and Elysium App tandem with custom configuration.

Types

type BlockFetcher

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

func NewBlockFetcher

func NewBlockFetcher(client Client) *BlockFetcher

NewBlockFetcher returns a new `BlockFetcher`.

func (*BlockFetcher) Commit

func (f *BlockFetcher) Commit(ctx context.Context, height *int64) (*types.Commit, error)

Commit queries Core for a `Commit` from the block at the given height.

func (*BlockFetcher) GetBlock

func (f *BlockFetcher) GetBlock(ctx context.Context, height *int64) (*types.Block, error)

GetBlock queries Core for a `Block` at the given height.

func (*BlockFetcher) GetBlockByHash

func (f *BlockFetcher) GetBlockByHash(ctx context.Context, hash libhead.Hash) (*types.Block, error)

func (*BlockFetcher) GetBlockInfo

func (f *BlockFetcher) GetBlockInfo(ctx context.Context, height *int64) (*types.Commit, *types.ValidatorSet, error)

GetBlockInfo queries Core for additional block information, like Commit and ValidatorSet.

func (*BlockFetcher) GetSignedBlock

func (f *BlockFetcher) GetSignedBlock(ctx context.Context, height *int64) (*coretypes.ResultSignedBlock, error)

GetSignedBlock queries Core for a `Block` at the given height.

func (*BlockFetcher) IsSyncing

func (f *BlockFetcher) IsSyncing(ctx context.Context) (bool, error)

IsSyncing returns the sync status of the Core connection: true for syncing, and false for already caught up. It can also return an error in the case of a failed status request.

func (*BlockFetcher) SubscribeNewBlockEvent

func (f *BlockFetcher) SubscribeNewBlockEvent(ctx context.Context) (<-chan types.EventDataSignedBlock, error)

SubscribeNewBlockEvent subscribes to new block events from Core, returning a new block event channel on success.

func (*BlockFetcher) UnsubscribeNewBlockEvent

func (f *BlockFetcher) UnsubscribeNewBlockEvent(ctx context.Context) error

UnsubscribeNewBlockEvent stops the subscription to new block events from Core.

func (*BlockFetcher) ValidatorSet

func (f *BlockFetcher) ValidatorSet(ctx context.Context, height *int64) (*types.ValidatorSet, error)

ValidatorSet queries Core for the ValidatorSet from the block at the given height.

type Client

type Client = client.Client

Client is an alias to Core Client.

func NewRemote

func NewRemote(ip, port string) (Client, error)

NewRemote creates a new Client that communicates with a remote Core endpoint over HTTP.

type Exchange

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

func NewExchange

func NewExchange(
	fetcher *BlockFetcher,
	store *eds.Store,
	construct header.ConstructFn,
) *Exchange

func (*Exchange) Get

func (ce *Exchange) Get(ctx context.Context, hash libhead.Hash) (*header.ExtendedHeader, error)

func (*Exchange) GetByHeight

func (ce *Exchange) GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error)

func (*Exchange) GetRangeByHeight

func (ce *Exchange) GetRangeByHeight(ctx context.Context, from, amount uint64) ([]*header.ExtendedHeader, error)

func (*Exchange) GetVerifiedRange

func (ce *Exchange) GetVerifiedRange(
	ctx context.Context,
	from *header.ExtendedHeader,
	amount uint64,
) ([]*header.ExtendedHeader, error)

func (*Exchange) Head

func (ce *Exchange) Head(ctx context.Context) (*header.ExtendedHeader, error)

type Listener

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

Listener is responsible for listening to Core for new block events and converting new Core blocks into the main data structure used in the Elysium DA network: `ExtendedHeader`. After digesting the Core block, extending it, and generating the `ExtendedHeader`, the Listener broadcasts the new `ExtendedHeader` to the header-sub gossipsub network.

func NewListener

func NewListener(
	bcast libhead.Broadcaster[*header.ExtendedHeader],
	fetcher *BlockFetcher,
	hashBroadcaster shrexsub.BroadcastFn,
	construct header.ConstructFn,
	store *eds.Store,
	blocktime time.Duration,
) *Listener

func (*Listener) Start

func (cl *Listener) Start(context.Context) error

Start kicks off the Listener listener loop.

func (*Listener) Stop

func (cl *Listener) Stop(context.Context) error

Stop stops the listener loop.

type TestConfig

type TestConfig struct {
	ConsensusParams *tmproto.ConsensusParams
	Tendermint      *tmconfig.Config
	App             *appconfig.Config

	Accounts     []string
	SuppressLogs bool
}

TestConfig encompasses all the configs required to run test Tendermint + Elysium App tandem.

func DefaultTestConfig

func DefaultTestConfig() *TestConfig

DefaultTestConfig returns the default testing configuration for Tendermint + Elysium App tandem.

It fetches free ports from OS and sets them into configs, s.t. user can make use of them(unlike 0 port) and allowing to run multiple tests nodes in parallel.

Additionally, it instructs Tendermint + Elysium App tandem to setup 10 funded accounts.

Jump to

Keyboard shortcuts

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