Documentation
¶
Index ¶
- Constants
- Variables
- func Init(path string, tp Type, options ...Option) error
- func IsInit(path string, tp Type) bool
- func SaveConfig(path string, cfg *Config) error
- type Config
- type ConfigLoader
- type Node
- type Option
- func WithBootstrapPeers(addrs []string) Option
- func WithConfig(custom *Config) Option
- func WithCoreClient(client core.Client) Option
- func WithHost(host host.Host) Option
- func WithMutualPeers(addrs []string) Option
- func WithP2PKey(key crypto.PrivKey) Option
- func WithP2PKeyStr(key string) Option
- func WithRemoteCore(protocol string, address string) Option
- func WithTrustedHash(hash string) Option
- func WithTrustedPeer(addr string) Option
- type Store
- type Type
Constants ¶
const Timeout = time.Second * 15
Variables ¶
var ( // ErrOpened is thrown on attempt to open already open/in-use Store. ErrOpened = errors.New("node: store is in use") // ErrNotInited is thrown on attempt to open Store without initialization. ErrNotInited = errors.New("node: store is not initialized") )
Functions ¶
func Init ¶
Init initializes the Node FileSystem Store for the given Node Type 'tp' in the directory under 'path' with default Config. Options are applied over default Config and persisted on disk.
func IsInit ¶
IsInit checks whether FileSystem Store was setup under given 'path'. If any required file/subdirectory does not exist, then false is reported.
func SaveConfig ¶
SaveConfig saves Config 'cfg' under the given 'path'.
Types ¶
type Config ¶
Config is main configuration structure for a Node. It combines configuration units for all Node subsystems.
func DefaultConfig ¶
DefaultConfig provides a default Config for a given Node Type 'tp'. NOTE: Currently, configs are identical, but this will change.
func LoadConfig ¶
LoadConfig loads Config from the given 'path'.
func (*Config) Encode ¶
TODO(@Wondertan): We should have a description for each field written into w,
so users can instantly understand purpose of each field. Ideally, we should have a utility program to parse comments from actual sources(*.go files) and generate docs from comments. Hint: use 'ast' package.
WriteTo flushes a given Config into w.
type ConfigLoader ¶
ConfigLoader defines a function that loads a config from any source.
type Node ¶
type Node struct { Type Type Config *Config // CoreClient provides access to a Core node process. CoreClient core.Client `optional:"true"` // RPCServer provides access to Node's exposed APIs. RPCServer *rpc.Server `optional:"true"` // p2p components Host host.Host ConnGater connmgr.ConnectionGater Routing routing.PeerRouting DataExchange exchange.Interface DAG format.DAGService // p2p protocols PubSub *pubsub.PubSub // BlockService provides access to the node's Block Service BlockServ *block.Service `optional:"true"` HeaderServ *header.Service // not optional DASer *das.DASer `optional:"true"` // contains filtered or unexported fields }
Node represents the core structure of a Celestia node. It keeps references to all Celestia-specific components and services in one place and provides flexibility to run a Celestia node in different modes. Currently supported modes: * Bridge * Light
func (*Node) Run ¶
Run is a Start which blocks on the given context 'ctx' until it is canceled. If canceled, the Node is still in the running state and should be gracefully stopped via Stop.
type Option ¶
Option for Node's Config.
func WithBootstrapPeers ¶ added in v0.2.0
WithBootstrapPeers sets the `BootstrapPeers` field in the config.
func WithCoreClient ¶ added in v0.2.0
WithCoreClient sets custom client for core process
func WithMutualPeers ¶ added in v0.2.0
WithMutualPeers sets the `MutualPeers` field in the config.
func WithP2PKey ¶ added in v0.2.0
WithP2PKey sets custom Ed25519 private key for p2p networking.
func WithP2PKeyStr ¶ added in v0.2.0
WithP2PKeyStr sets custom hex encoded Ed25519 private key for p2p networking.
func WithRemoteCore ¶
WithRemoteCore configures Node to start with remote Core.
func WithTrustedHash ¶
WithTrustedHash sets TrustedHash to the Config.
func WithTrustedPeer ¶
WithTrustedPeer appends TrustedPeer to the Config.
type Store ¶ added in v0.2.0
type Store interface { // Path reports the FileSystem path of Store. Path() string // Keystore provides a Keystore to access keys. Keystore() (keystore.Keystore, error) // Datastore provides a Datastore - a KV store for arbitrary data to be stored on disk. Datastore() (datastore.Batching, error) // Core provides an access to Core's Store. Core() (core.Store, error) // Config loads the stored Node config. Config() (*Config, error) // PutConfig alters the stored Node config. PutConfig(*Config) error // Close closes the Store freeing up acquired resources and locks. Close() error }
Store encapsulates storage for the Node. Basically, it is the Store of all Stores. It provides access for the Node data stored in root directory e.g. '~/.celestia'.
func NewMemStore ¶ added in v0.2.0
func NewMemStore() Store
NewMemStore creates an in-memory Store for Node. Useful for testing.
func OpenStore ¶ added in v0.2.0
OpenStore creates new FS Store under the given 'path'. To be opened the Store must be initialized first, otherwise ErrNotInited is thrown. OpenStore takes a file Lock on directory, hence only one Store can be opened at a time under the given 'path', otherwise ErrOpened is thrown.
type Type ¶
type Type uint8
Type defines the Node type (e.g. `light`, `bridge`) for identity purposes. The zero value for Type is invalid.
const ( // Bridge is a Celestia Node that bridges the Celestia consensus network and data availability network. // It maintains a trusted channel/connection to a Celestia Core node via the core.Client API. Bridge Type = iota + 1 // Light is a stripped-down Celestia Node which aims to be lightweight while preserving highest possible // security guarantees. Light )