statesync

package
v0.0.0-...-4ef5390 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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 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,
	localPeerID p2p.ID,
) *Reactor

NewReactor creates a new state sync reactor. Our state sync reactor is simple. It will only forward req/resp to and from our first remote peer. Our first remote peer is expected to be one of our upstream/persistent peers. If that remote peer results in our local node/peer blacklisting us, i.e. rejects the remote peer's snapshot/chunks, user will need to remove that upstream peer and restart the node. Improvements can be made to query all our remote peers, choose the best snapshot, and serve that snapshot to our local node. Snapshot discovery time may need to increase since the local node's state sync may have started before tiasync has connected to it. For example, a 15 second discovery time could be less due to this latency. If we query multiple nodes for the best snapshot, local node/cometbft's discovery time will need to be: tiasync startup latency + tiasync discovery time + tiasync snapshot response latency.

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. Forwards requests to our first remote peer (upstream/persistent peer) Forwards responses to our local node

func (*Reactor) RemovePeer

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

RemovePeer implements p2p.Reactor.

Jump to

Keyboard shortcuts

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