node

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package node is the main entry point, where the Node struct, which represents a full node, is defined.

Adding new p2p.Reactor(s)

To add a new p2p.Reactor, use the CustomReactors option:

node, err := NewNode(
		config,
		privVal,
		nodeKey,
		clientCreator,
		genesisDocProvider,
		dbProvider,
		logger,
		CustomReactors(map[string]p2p.Reactor{"CUSTOM": customReactor}),
)

Replacing existing p2p.Reactor(s)

To replace the built-in p2p.Reactor, use the CustomReactors option:

node, err := NewNode(
		config,
		privVal,
		nodeKey,
		clientCreator,
		genesisDocProvider,
		dbProvider,
		logger,
		CustomReactors(map[string]p2p.Reactor{"BLOCKCHAIN": customBlockchainReactor}),
)

The list of existing reactors can be found in CustomReactors documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDBProvider

func DefaultDBProvider(ctx *DBContext) (dbm.DB, error)

DefaultDBProvider returns a database using the db.Backend 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 and persists the result to the database. On success this also returns the genesis doc loaded through the given provider.

AppState is intentionally not persisted in the state DB (it can be huge — hundreds of MB on real-world genesis files — and may carry types that the codec cannot encode, such as on-disk-backed handles). The DB copy is an audit trail for ChainID / Validators / GenesisTime / AppHash. Whenever the loaded doc has no AppState attached, the provider is re-invoked to supply it. AppState is only consumed at appBlockHeight==0 (see consensus/replay.go ReplayBlocks), so this re-derivation is cheap and safe — beyond that height the field is unused.

Types

type DBContext

type DBContext struct {
	ID     string
	Config *cfg.Config
}

DBContext specifies config information for loading a new DB.

type DBProvider

type DBProvider func(*DBContext) (dbm.DB, error)

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(genesisFile string) GenesisDocProvider

DefaultGenesisDocProviderFunc returns a GenesisDocProvider that loads the GenesisDoc from the genesis path on the filesystem.

type Node

type Node struct {
	service.BaseService
	// contains filtered or unexported fields
}

Node is the highest level interface to a full Tendermint node. It includes all configuration information and running services.

func DefaultNewNode

func DefaultNewNode(
	config *cfg.Config,
	genesisFile string,
	evsw events.EventSwitch,
	logger *slog.Logger,
	options ...Option,
) (*Node, error)

DefaultNewNode returns a Tendermint node with default settings for the PrivValidator, ClientCreator, GenesisDoc, and DBProvider. It implements NodeProvider.

func DefaultNewNodeWithGenesisProvider

func DefaultNewNodeWithGenesisProvider(
	config *cfg.Config,
	genesisDocProvider GenesisDocProvider,
	evsw events.EventSwitch,
	logger *slog.Logger,
	options ...Option,
) (*Node, error)

DefaultNewNodeWithGenesisProvider returns a Tendermint node with default settings for the PrivValidator, ClientCreator, and DBProvider, but uses the supplied GenesisDocProvider in place of the on-disk loader. This is the seam callers use to inject custom genesis loading (for example, a streaming loader that avoids reading the entire genesis file into memory).

func NewNode

func NewNode(config *cfg.Config,
	privValidator types.PrivValidator,
	nodeKey *p2pTypes.NodeKey,
	clientCreator appconn.ClientCreator,
	genesisDocProvider GenesisDocProvider,
	dbProvider DBProvider,
	evsw events.EventSwitch,
	logger *slog.Logger,
	options ...Option,
) (*Node, error)

NewNode returns a new, ready to go, Tendermint Node.

func (*Node) BlockStore

func (n *Node) BlockStore() *store.BlockStore

BlockStore returns the Node's BlockStore.

func (*Node) Config

func (n *Node) Config() *cfg.Config

Config returns the Node's config.

func (*Node) ConsensusReactor

func (n *Node) ConsensusReactor() *cs.ConsensusReactor

ConsensusReactor returns the Node's ConsensusReactor.

func (*Node) ConsensusState

func (n *Node) ConsensusState() *cs.ConsensusState

ConsensusState returns the Node's ConsensusState.

func (*Node) EventSwitch

func (n *Node) EventSwitch() events.EventSwitch

EventSwitch returns the node's EventSwitch.

func (*Node) GenesisDoc

func (n *Node) GenesisDoc() *types.GenesisDoc

GenesisDoc returns the Node's GenesisDoc.

func (*Node) IsListening

func (n *Node) IsListening() bool

func (*Node) Listeners

func (n *Node) Listeners() []string

func (*Node) Mempool

func (n *Node) Mempool() mempl.Mempool

Mempool returns the Node's mempool.

func (*Node) MempoolReactor

func (n *Node) MempoolReactor() *mempl.Reactor

MempoolReactor returns the Node's mempool reactor.

func (*Node) NodeInfo

func (n *Node) NodeInfo() p2pTypes.NodeInfo

NodeInfo returns the Node's Info from the Switch.

func (*Node) OnStart

func (n *Node) OnStart() error

OnStart starts the Node. It implements service.Service.

func (*Node) OnStop

func (n *Node) OnStop()

OnStop stops the Node. It implements service.Service.

func (*Node) PrivValidator

func (n *Node) PrivValidator() types.PrivValidator

PrivValidator returns the Node's PrivValidator. XXX: for convenience only!

func (*Node) ProxyApp

func (n *Node) ProxyApp() appconn.AppConns

ProxyApp returns the Node's AppConns, representing its connections to the ABCI application.

func (*Node) RPCEnvironment

func (n *Node) RPCEnvironment() *rpccore.Environment

RPCEnvironment returns the per-node RPC Environment. It is populated by configureRPC during OnStart and is nil before the node has started. rpc/client.NewLocal needs this to dispatch handler calls without going over the network.

func (*Node) Ready

func (n *Node) Ready() <-chan struct{}

Ready signals that the node is ready by returning a blocking channel. This channel is closed when the node receives its first block.

func (*Node) Switch

func (n *Node) Switch() *p2p.MultiplexSwitch

Switch returns the Node's Switch.

type NodeGreeting

type NodeGreeting struct {
	NodeID
	Version string
	ChainID string
	Message string
	Time    time.Time
}

type NodeID

type NodeID struct {
	Name   string
	PubKey crypto.PubKey
}

type NodeProvider

type NodeProvider func(*cfg.Config, *slog.Logger) (*Node, error)

NodeProvider takes a config and a logger and returns a ready to go Node.

type Option

type Option func(*Node)

Option sets a parameter for the node.

func WithEarlyStart

func WithEarlyStart() Option

WithEarlyStart starts RPC and P2P before genesis time, deferring only consensus until the genesis timestamp is reached.

type PrivNodeID

type PrivNodeID struct {
	NodeID
	PrivKey crypto.PrivKey
}

func (*PrivNodeID) SignGreeting

func (pnid *PrivNodeID) SignGreeting() *SignedNodeGreeting

type SignedNodeGreeting

type SignedNodeGreeting struct {
	NodeGreeting
	Signature []byte
}

Jump to

Keyboard shortcuts

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