statesync

package
v0.34.22 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SnapshotChannel exchanges snapshot metadata
	SnapshotChannel = byte(0x60)
	// ChunkChannel exchanges chunk contents
	ChunkChannel = byte(0x61)
)
View Source
const (
	// MetricsSubsystem is a subsystem shared by all metrics exposed by this
	// package.
	MetricsSubsystem = "statesync"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	// Whether or not a node is state syncing. 1 if yes, 0 if no.
	Syncing metrics.Gauge
}

Metrics contains metrics exposed by this package.

func NopMetrics

func NopMetrics() *Metrics

func PrometheusMetrics

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

type Reactor

type Reactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

Reactor handles state sync, both restoring snapshots for the local node and serving snapshots for other nodes.

func NewReactor

func NewReactor(
	cfg config.StateSyncConfig,
	conn proxy.AppConnSnapshot,
	connQuery proxy.AppConnQuery,
	tempDir string,
	metrics *Metrics,
) *Reactor

NewReactor creates a new state sync reactor.

func (*Reactor) AddPeer

func (r *Reactor) AddPeer(peer p2p.Peer)

AddPeer implements p2p.Reactor.

func (*Reactor) GetChannels

func (r *Reactor) GetChannels() []*p2p.ChannelDescriptor

GetChannels implements p2p.Reactor.

func (*Reactor) OnStart

func (r *Reactor) OnStart() error

OnStart implements p2p.Reactor.

func (*Reactor) Receive

func (r *Reactor) Receive(e p2p.Envelope)

Receive implements p2p.Reactor.

func (*Reactor) RemovePeer

func (r *Reactor) RemovePeer(peer p2p.Peer, reason interface{})

RemovePeer implements p2p.Reactor.

func (*Reactor) Sync

func (r *Reactor) Sync(stateProvider StateProvider, discoveryTime time.Duration) (sm.State, *types.Commit, error)

Sync runs a state sync, returning the new state and last commit at the snapshot height. The caller must store the state and commit in the state database and block store.

type StateProvider

type StateProvider interface {
	// AppHash returns the app hash after the given height has been committed.
	AppHash(ctx context.Context, height uint64) ([]byte, error)
	// Commit returns the commit at the given height.
	Commit(ctx context.Context, height uint64) (*types.Commit, error)
	// State returns a state object at the given height.
	State(ctx context.Context, height uint64) (sm.State, error)
}

StateProvider is a provider of trusted state data for bootstrapping a node. This refers to the state.State object, not the state machine.

func NewLightClientStateProvider

func NewLightClientStateProvider(
	ctx context.Context,
	chainID string,
	version tmstate.Version,
	initialHeight int64,
	servers []string,
	trustOptions light.TrustOptions,
	logger log.Logger,
) (StateProvider, error)

NewLightClientStateProvider creates a new StateProvider using a light client and RPC clients.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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