Documentation ¶
Index ¶
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 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) GetChannels ¶
func (r *Reactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements p2p.Reactor.
func (*Reactor) Receive ¶
Receive implements p2p.Reactor. Forwards requests to our first remote peer (upstream/persistent peer) Forwards responses to our local node
func (*Reactor) RemovePeer ¶
RemovePeer implements p2p.Reactor.