core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 25 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInited = errors.New("core: repository is not initialized")

ErrNotInited is used to signal when core is intended to be started without being initialized.

Functions

func Init

func Init(path string) (err error)

Init checks each item of the list(below) for existence in the path. If latter(item) is not existing, then it(func Init) creates them by default settings List of items: * Config * Private validator key * P2P comms private key * Stub genesis doc file

func IsInit

func IsInit(path string) bool

IsInit checks whether the Core is initialized under the given 'path'. It requires Config, Private Validator Key, Private P2P Key and genesis doc.

func SaveConfig

func SaveConfig(path string, cfg *Config) error

SaveConfig saves config in a file under the given 'path'.

func StartMockNode

func StartMockNode() *node.Node

StartMockNode starts a mock Core node background process and returns it.

func StartRemoteCore

func StartRemoteCore() (*node.Node, string, string)

StartRemoteCore starts a remote core and returns it's protocol and address

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 tmbytes.HexBytes) (*types.Block, error)

func (*BlockFetcher) SubscribeNewBlockEvent

func (f *BlockFetcher) SubscribeNewBlockEvent(ctx context.Context) (<-chan *types.Block, 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 MockEmbeddedClient

func MockEmbeddedClient() Client

MockEmbeddedClient returns a started mock Core Client.

func NewEmbedded

func NewEmbedded(cfg *Config) (Client, error)

NewEmbedded returns a new Client from an embedded Core node process.

func NewEmbeddedFromNode

func NewEmbeddedFromNode(node *corenode.Node) Client

NewEmbeddedFromNode wraps a given Core node process to be able to control its lifecycle.

func NewRemote

func NewRemote(protocol, remoteAddr string) (Client, error)

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

func StartRemoteClient

func StartRemoteClient() (*node.Node, Client, error)

StartRemoteClient returns a started remote Core node process, as well its mock Core Client.

type Config

type Config = config.Config

Config is an alias for Core config. For the simplicity of future config changes, the alias should be used throughout celestia-node codebase/repo

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a modified default config of Core node.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads the config from the file under the given 'path'. NOTE: Unfortunately, Core(Tendermint) does not provide us with convenient function to load the Config, so we have to do our own. Furthermore, we have to make own SaveConfig, as the one the Core provides has incompatibility issues with our toml parser version.

func MockConfig

func MockConfig(t *testing.T) *Config

MockConfig provides a testing configuration for embedded Core Client.

type RepoLoader

type RepoLoader func() (Repository, error)

RepoLoader loads the Repository.

type Repository

type Repository interface {
	// Config loads a Config.
	Config() (*Config, error)
	// PutConfig saves given config.
	PutConfig(*Config) error
}

TODO(@Wondertan):

  • This should expose GenesisDoc and others. We can add them ad-hoc.
  • Ideally, add private keys to Keystore to unify access pattern.

func NewMemRepository

func NewMemRepository() Repository

NewMemRepository creates in memory implementation of Repository

func Open

func Open(path string) (Repository, error)

Open instantiates FileSystem(FS) Repository from a given 'path'.

Jump to

Keyboard shortcuts

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