Documentation ¶
Overview ¶
Package pullsync contains protocol that is used to ensure that there is correct chunk replication in the neighborhood of the node.
The protocol is used to exchange information about what chunks are stored on other nodes and if necessary pull any chunks it needs. It also takes care that chunks are not synced twice.
The pullsync protocol uses Protobuf messages for encoding. It then exposes several functions which use those messages to start the exchange of other node cursors using `GetCursors` function, after which node can schedule syncing of chunks using `SyncInterval` function, and in the case of any errors or timed-out operations cancel syncing using `CancelRuid`.
Package pullsync provides the pullsync protocol implementation.
Index ¶
- Constants
- Variables
- type Interface
- type Syncer
- func (s *Syncer) Close() error
- func (s *Syncer) GetCursors(ctx context.Context, peer swarm.Address) (retr []uint64, epoch uint64, err error)
- func (s *Syncer) Metrics() []prometheus.Collector
- func (s *Syncer) Protocol() p2p.ProtocolSpec
- func (s *Syncer) Sync(ctx context.Context, peer swarm.Address, bin uint8, start uint64) (uint64, int, error)
Constants ¶
const ( MaxCursor = math.MaxUint64 DefaultMaxPage uint64 = 250 )
Variables ¶
var (
ErrUnsolicitedChunk = errors.New("peer sent unsolicited chunk")
)
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { // Sync syncs a batch of chunks starting at a start BinID. // It returns the BinID of highest chunk that was synced from the given // batch and the total number of chunks the downstream peer has sent. Sync(ctx context.Context, peer swarm.Address, bin uint8, start uint64) (topmost uint64, count int, err error) // GetCursors retrieves all cursors from a downstream peer. GetCursors(ctx context.Context, peer swarm.Address) ([]uint64, uint64, error) }
Interface is the PullSync interface.
type Syncer ¶
func (*Syncer) GetCursors ¶
func (*Syncer) Metrics ¶
func (s *Syncer) Metrics() []prometheus.Collector
func (*Syncer) Protocol ¶
func (s *Syncer) Protocol() p2p.ProtocolSpec
func (*Syncer) Sync ¶
func (s *Syncer) Sync(ctx context.Context, peer swarm.Address, bin uint8, start uint64) (uint64, int, error)
Sync syncs a batch of chunks starting at a start BinID. It returns the BinID of highest chunk that was synced from the given batch and the total number of chunks the downstream peer has sent.