Documentation ¶
Overview ¶
Package node is the main entry point, where the Node struct, which represents a full node, is defined.
Adding new p2p.Handler(s)
To add a new p2p.Handler, use the CustomHandlers option:
node, err := NewNode( config, privVal, nodeKey, clientCreator, genesisDocProvider, dbProvider, metricsProvider, logger, CustomHandlers(map[string]p2p.Handler{"CUSTOM": customHandler}), )
Replacing existing p2p.Handler(s)
To replace the built-in p2p.Handler, use the CustomHandlers option:
node, err := NewNode( config, privVal, nodeKey, clientCreator, genesisDocProvider, dbProvider, metricsProvider, logger, CustomHandlers(map[string]p2p.Handler{"BLOCKCHAIN": customBlockchainHandler}), )
The list of existing reactors can be found in CustomHandlers documentation.
Index ¶
- func DefaultDBProvider(ctx *DBContext) (dbm.DB, error)
- func LoadStateFromDBOrGenesisDocProvider(stateDB dbm.DB, genesisDocProvider GenesisDocProvider) (sm.State, *types.GenesisDoc, error)
- type DBContext
- type DBProvider
- type GenesisDocProvider
- type Greeting
- type ID
- type MetricsProvider
- type Node
- func (n *Node) BlockStore() *store.BlockStore
- func (n *Node) Config() *cfg.Config
- func (n *Node) ConfigureRPC() error
- func (n *Node) ConsensusHandler() *cs.Handler
- func (n *Node) ConsensusState() *cs.State
- func (n *Node) EventBus() *types.EventBus
- func (n *Node) EvidencePool() *evidence.Pool
- func (n *Node) GenesisDoc() *types.GenesisDoc
- func (n *Node) IsListening() bool
- func (n *Node) Listeners() []string
- func (n *Node) Mempool() mempl.Mempool
- func (n *Node) MempoolHandler() p2p.Handler
- func (n *Node) NodeInfo() p2p.NodeInfo
- func (n *Node) OnStart() error
- func (n *Node) OnStop()
- func (n *Node) PEXHandler() *pex.Handler
- func (n *Node) PrivValidator() types.PrivValidator
- func (n *Node) ProxyApp() proxy.AppConns
- func (n *Node) Switch() *p2p.Switch
- type Option
- type PrivNodeID
- type Provider
- type SignedNodeGreeting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDBProvider ¶
DefaultDBProvider returns a database using the DBBackend and DBDir specified in the ctx.Config.
func LoadStateFromDBOrGenesisDocProvider ¶
func LoadStateFromDBOrGenesisDocProvider( stateDB dbm.DB, genesisDocProvider GenesisDocProvider, ) (sm.State, *types.GenesisDoc, error)
LoadStateFromDBOrGenesisDocProvider attempts to load the state from the database, or creates one using the given genesisDocProvider. On success this also returns the genesis doc loaded through the given provider.
Types ¶
type DBProvider ¶
DBProvider takes a DBContext and returns an instantiated DB.
type GenesisDocProvider ¶
type GenesisDocProvider func() (*types.GenesisDoc, error)
GenesisDocProvider returns a GenesisDoc. It allows the GenesisDoc to be pulled from sources other than the filesystem, for instance from a distributed key-value store cluster.
func DefaultGenesisDocProviderFunc ¶
func DefaultGenesisDocProviderFunc(config *cfg.Config) GenesisDocProvider
DefaultGenesisDocProviderFunc returns a GenesisDocProvider that loads the GenesisDoc from the config.GenesisFile() on the filesystem.
type MetricsProvider ¶
type MetricsProvider func(chainID string) (*cs.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.Metrics, *proxy.Metrics)
MetricsProvider returns a consensus, p2p and mempool Metrics.
func DefaultMetricsProvider ¶
func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider
DefaultMetricsProvider returns Metrics build using Prometheus client library if Prometheus is enabled. Otherwise, it returns no-op Metrics.
type Node ¶
type Node struct { service.BaseService // contains filtered or unexported fields }
Node is the highest level interface to a full CometBFT node. It includes all configuration information and running services.
func DefaultNewNode ¶
DefaultNewNode returns a CometBFT node with default settings for the PrivValidator, ClientCreator, GenesisDoc, and DBProvider. It implements NodeProvider.
func NewNode ¶
func NewNode(config *cfg.Config, privValidator types.PrivValidator, nodeKey *p2p.NodeKey, clientCreator proxy.ClientCreator, genesisDocProvider GenesisDocProvider, dbProvider DBProvider, metricsProvider MetricsProvider, logger log.Logger, options ...Option, ) (*Node, error)
NewNode returns a new, ready to go, CometBFT Node.
func (*Node) BlockStore ¶
func (n *Node) BlockStore() *store.BlockStore
BlockStore returns the Node's BlockStore.
func (*Node) ConfigureRPC ¶
ConfigureRPC makes sure RPC has all the objects it needs to operate.
func (*Node) ConsensusHandler ¶
ConsensusHandler returns the Node's ConsensusHandler.
func (*Node) ConsensusState ¶
ConsensusState returns the Node's ConsensusState.
func (*Node) EvidencePool ¶
EvidencePool returns the Node's EvidencePool.
func (*Node) GenesisDoc ¶
func (n *Node) GenesisDoc() *types.GenesisDoc
GenesisDoc returns the Node's GenesisDoc.
func (*Node) IsListening ¶
func (*Node) MempoolHandler ¶
MempoolHandler returns the Node's mempool reactor.
func (*Node) PEXHandler ¶
PEXHandler returns the Node's PEXHandler. It returns nil if PEX is disabled.
func (*Node) PrivValidator ¶
func (n *Node) PrivValidator() types.PrivValidator
PrivValidator returns the Node's PrivValidator. XXX: for convenience only!
type Option ¶
type Option func(*Node)
Option sets a parameter for the node.
func CustomHandlers ¶
CustomHandlers allows you to add custom reactors (name -> p2p.Handler) to the node's Switch.
WARNING: using any name from the below list of the existing reactors will result in replacing it with the custom one.
- MEMPOOL
- BLOCKCHAIN
- CONSENSUS
- EVIDENCE
- PEX
- STATESYNC
func StateProvider ¶
func StateProvider(stateProvider statesync.StateProvider) Option
StateProvider overrides the state provider used by state sync to retrieve trusted app hashes and build a State object for bootstrapping the node. WARNING: this interface is considered unstable and subject to change.
type PrivNodeID ¶
func (*PrivNodeID) SignGreeting ¶
func (pnid *PrivNodeID) SignGreeting() *SignedNodeGreeting