Documentation ¶
Index ¶
- Constants
- type Handler
- func (r *Handler) AddPeer(peer p2p.Peer)
- func (r *Handler) GetChannels() []*p2p.ChannelDescriptor
- func (r *Handler) OnStart() error
- func (r *Handler) ReceiveEventMessage(e p2p.EventMessage)
- func (r *Handler) RemovePeer(peer p2p.Peer, reason interface{})
- func (r *Handler) Sync(stateProvider StateProvider, discoveryTime time.Duration) (sm.State, *types.Commit, error)
- type StateProvider
Constants ¶
const ( // SnapshotChannel exchanges snapshot metadata SnapshotChannel = byte(0x60) // ChunkChannel exchanges chunk contents ChunkChannel = byte(0x61) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { p2p.BaseHandler // contains filtered or unexported fields }
Handler handles state sync, both restoring snapshots for the local node and serving snapshots for other nodes.
func NewHandler ¶
func NewHandler( cfg config.StateSyncConfig, conn proxy.AppConnSnapshot, connQuery proxy.AppConnQuery, tempDir string, ) *Handler
NewHandler creates a new state sync reactor.
func (*Handler) GetChannels ¶
func (r *Handler) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements p2p.Handler.
func (*Handler) ReceiveEventMessage ¶
func (r *Handler) ReceiveEventMessage(e p2p.EventMessage)
Receive implements p2p.Handler.
func (*Handler) RemovePeer ¶
RemovePeer implements p2p.Handler.
func (*Handler) Sync ¶
func (r *Handler) 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 cmtstate.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.