node

package
v0.0.0-...-6dcdc0e Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 54 Imported by: 0

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

func ParseMisbehaviors

func ParseMisbehaviors(str string) (map[int64]cs.Misbehavior, error)

ParseMisbehaviors is a util function that converts a comma separated string into a map of misbehaviors to be executed by the maverick node

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 FilePV

type FilePV struct {
	Key           FilePVKey
	LastSignState FilePVLastSignState
}

FilePV implements PrivValidator using data persisted to disk to prevent double signing. NOTE: the directories containing pv.Key.filePath and pv.LastSignState.filePath must already exist. It includes the LastSignature and LastSignBytes so we don't lose the signature if the process crashes after signing but before the resulting consensus message is processed.

func GenFilePV

func GenFilePV(keyFilePath, stateFilePath string) *FilePV

GenFilePV generates a new validator with randomly generated private key and sets the filePaths, but does not call Save().

func LoadFilePV

func LoadFilePV(keyFilePath, stateFilePath string) *FilePV

LoadFilePV loads a FilePV from the filePaths. The FilePV handles double signing prevention by persisting data to the stateFilePath. If either file path does not exist, the program will exit.

func LoadFilePVEmptyState

func LoadFilePVEmptyState(keyFilePath, stateFilePath string) *FilePV

LoadFilePVEmptyState loads a FilePV from the given keyFilePath, with an empty LastSignState. If the keyFilePath does not exist, the program will exit.

func LoadOrGenFilePV

func LoadOrGenFilePV(keyFilePath, stateFilePath string) *FilePV

LoadOrGenFilePV loads a FilePV from the given filePaths or else generates a new one and saves it to the filePaths.

func (*FilePV) GetAddress

func (pv *FilePV) GetAddress() types.Address

GetAddress returns the address of the validator. Implements PrivValidator.

func (*FilePV) GetPubKey

func (pv *FilePV) GetPubKey() (crypto.PubKey, error)

GetPubKey returns the public key of the validator. Implements PrivValidator.

func (*FilePV) Reset

func (pv *FilePV) Reset()

Reset resets all fields in the FilePV. NOTE: Unsafe!

func (*FilePV) Save

func (pv *FilePV) Save()

Save persists the FilePV to disk.

func (*FilePV) SignProposal

func (pv *FilePV) SignProposal(chainID string, proposal *tmproto.Proposal) error

SignProposal signs a canonical representation of the proposal, along with the chainID. Implements PrivValidator.

func (*FilePV) SignVote

func (pv *FilePV) SignVote(chainID string, vote *tmproto.Vote) error

SignVote signs a canonical representation of the vote, along with the chainID. Implements PrivValidator.

func (*FilePV) String

func (pv *FilePV) String() string

String returns a string representation of the FilePV.

type FilePVKey

type FilePVKey struct {
	Address types.Address  `json:"address"`
	PubKey  crypto.PubKey  `json:"pub_key"`
	PrivKey crypto.PrivKey `json:"priv_key"`
	// contains filtered or unexported fields
}

FilePVKey stores the immutable part of PrivValidator.

func (FilePVKey) Save

func (pvKey FilePVKey) Save()

Save persists the FilePVKey to its filePath.

type FilePVLastSignState

type FilePVLastSignState struct {
	Height    int64            `json:"height"`
	Round     int32            `json:"round"`
	Step      int8             `json:"step"`
	Signature []byte           `json:"signature,omitempty"`
	SignBytes tmbytes.HexBytes `json:"signbytes,omitempty"`
	// contains filtered or unexported fields
}

FilePVLastSignState stores the mutable part of PrivValidator.

func (*FilePVLastSignState) CheckHRS

func (lss *FilePVLastSignState) CheckHRS(height int64, round int32, step int8) (bool, error)

CheckHRS checks the given height, round, step (HRS) against that of the FilePVLastSignState. It returns an error if the arguments constitute a regression, or if they match but the SignBytes are empty. The returned boolean indicates whether the last Signature should be reused - it returns true if the HRS matches the arguments and the SignBytes are not empty (indicating we have already signed for this HRS, and can reuse the existing signature). It panics if the HRS matches the arguments, there's a SignBytes, but no Signature.

func (*FilePVLastSignState) Save

func (lss *FilePVLastSignState) Save()

Save persists the FilePvLastSignState to its filePath.

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) (*consensus.Metrics, *p2p.Metrics, *mempl.Metrics, *sm.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 Tendermint node. It includes all configuration information and running services.

func DefaultNewNode

func DefaultNewNode(config *cfg.Config, logger log.Logger, misbehaviors map[int64]cs.Misbehavior) (*Node, error)

DefaultNewNode returns a Tendermint 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,
	misbehaviors map[int64]cs.Misbehavior,
	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) ConfigureRPC

func (n *Node) ConfigureRPC() error

ConfigureRPC makes sure RPC has all the objects it needs to operate.

func (*Node) ConsensusReactor

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

ConsensusReactor returns the Node's ConsensusReactor.

func (*Node) ConsensusState

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

ConsensusState returns the Node's ConsensusState.

func (*Node) EventBus

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

EventBus returns the Node's EventBus.

func (*Node) EvidencePool

func (n *Node) EvidencePool() *evidence.Pool

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 (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() p2p.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) PEXReactor

func (n *Node) PEXReactor() *pex.Reactor

PEXReactor returns the Node's PEXReactor. 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!

func (*Node) ProxyApp

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

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

func (*Node) Switch

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

Switch returns the Node's Switch.

type Option

type Option func(*Node)

Option sets a parameter for the node.

func CustomReactors

func CustomReactors(reactors map[string]p2p.Reactor) Option

CustomReactors allows you to add custom reactors (name -> p2p.Reactor) 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 CustomReactorsAsConstructors

func CustomReactorsAsConstructors(reactors map[string]func(n *Node) p2p.Reactor) Option

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 Provider

type Provider func(*cfg.Config, log.Logger) (*Node, error)

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

Jump to

Keyboard shortcuts

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