Documentation
¶
Index ¶
Constants ¶
const Timeout = time.Second * 15
Variables ¶
var ( // ErrOpened is thrown on attempt to open already open/in-use Repository. ErrOpened = errors.New("node: repository is in use") // ErrNotInited is thrown on attempt to open Repository without initialization. ErrNotInited = errors.New("node: repository is not initialized") )
Functions ¶
func Init ¶
Init initializes the Node FileSystem Repository 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 InitWith ¶
InitWith initializes the Node FileSystem Repository for the given Node Type 'tp' in the directory under 'path' with the given Config 'cfg'.
func IsInit ¶
IsInit checks whether FileSystem Repository 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
// TODO @renaynay: I don't like the concept of storing individual services on the node,
// TODO maybe create a struct in full.go that contains `FullServices` (all expected services to be running on a
// TODO full node) and in light, same thing `LightServices` (all expected services to be running in a light node.
// TODO `FullServices` can include `LightServices` + other services.
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: * Full * Light
func New ¶
func New(tp Type, repo Repository, options ...Option) (*Node, error)
New assembles a new Node with the given type 'tp' over Repository 'repo'.
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 ¶
type Option func(*Config)
Option for Node's Config.
func WithRemoteCore ¶
WithRemoteCore configures Node to start with remote Core.
func WithTrustedHash ¶
WithTrustedHash sets TrustedHash to the Config.
func WithTrustedPeer ¶
WithTrustedPeer sets TrustedPeer to the Config.
type Repository ¶
type Repository interface {
// Path reports the FileSystem path of Repository.
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 Repository.
Core() (core.Repository, error)
// Config loads the stored Node config.
Config() (*Config, error)
// PutConfig alters the stored Node config.
PutConfig(*Config) error
// Close closes the Repository freeing up acquired resources and locks.
Close() error
}
Repository encapsulates storage for the Node. It provides access for the Node data stored in root directory e.g. '~/.celestia'.
func MockRepository ¶
func MockRepository(t *testing.T, cfg *Config) Repository
MockRepository provides mock in memory Repository for testing purposes.
func NewMemRepository ¶
func NewMemRepository() Repository
NewMemRepository creates an in-memory Repository for Node. Useful for testing.
func Open ¶
func Open(path string, tp Type) (Repository, error)
Open creates new FS Repository under the given 'path'. To be opened the Repository must be initialized first, otherwise ErrNotInited is thrown. Open takes a file Lock on directory, hence only one Repository can be opened at a time under the given 'path', otherwise ErrOpened is thrown.