pullsync

package
v1.12.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: BSD-3-Clause Imports: 20 Imported by: 3

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

View Source
const MaxCursor = math.MaxUint64

Variables

View Source
var (
	ErrUnsolicitedChunk = errors.New("peer sent unsolicited chunk")
)

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// SyncInterval syncs a requested interval from the given peer.
	// It returns the BinID of highest chunk that was synced from the given
	// interval. If the requested interval is too large, the downstream peer
	// has the liberty to provide less chunks than requested.
	SyncInterval(ctx context.Context, peer swarm.Address, bin uint8, from, to uint64) (topmost uint64, err error)
	// GetCursors retrieves all cursors from a downstream peer.
	GetCursors(ctx context.Context, peer swarm.Address) ([]uint64, error)
}

Interface is the PullSync interface.

type Syncer

type Syncer struct {
	Interface
	io.Closer
	// contains filtered or unexported fields
}

func New

func New(streamer p2p.Streamer, storage pullstorage.Storer, unwrap func(swarm.Chunk), validStamp postage.ValidStampFn, logger log.Logger, radius postage.RadiusChecker, overlayAddress swarm.Address) *Syncer

func (*Syncer) Close

func (s *Syncer) Close() error

func (*Syncer) GetCursors

func (s *Syncer) GetCursors(ctx context.Context, peer swarm.Address) (retr []uint64, err error)

func (*Syncer) Metrics added in v0.2.0

func (s *Syncer) Metrics() []prometheus.Collector

func (*Syncer) Protocol

func (s *Syncer) Protocol() p2p.ProtocolSpec

func (*Syncer) SyncInterval

func (s *Syncer) SyncInterval(ctx context.Context, peer swarm.Address, bin uint8, from, to uint64) (uint64, error)

SyncInterval syncs a requested interval from the given peer. It returns the BinID of the highest chunk that was synced from the given interval. If the requested interval is too large, the downstream peer has the liberty to provide fewer chunks than requested.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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