{"modulePath":"github.com/ethersphere/bee","version":"v1.18.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pullsync\n\nPackage pullsync contains protocol that is used to ensure that there is correct chunk replication in the neighborhood of the node.\n\nThe 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.\n\nThe 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\\`.\n\nPackage pullsync provides the pullsync protocol implementation.\n\n## Constants\n\n```go\nconst (\n\tMaxCursor             = math.MaxUint64\n\tDefaultMaxPage uint64 = 250\n)\n```\n\n## Variables\n\n```go\nvar (\n\tErrUnsolicitedChunk = errors.New(\"peer sent unsolicited chunk\")\n)\n```\n\n## Types\n\n```go\ntype Interface interface {\n\t// Sync syncs a batch of chunks starting at a start BinID.\n\t// It returns the BinID of highest chunk that was synced from the given\n\t// batch and the total number of chunks the downstream peer has sent.\n\tSync(ctx context.Context, peer swarm.Address, bin uint8, start uint64) (topmost uint64, count int, err error)\n\t// GetCursors retrieves all cursors from a downstream peer.\n\tGetCursors(ctx context.Context, peer swarm.Address) ([]uint64, uint64, error)\n}\n```\nInterface is the PullSync interface.\n\n```go\ntype Syncer struct {\n\tInterface\n\tio.Closer\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc New(\n\tstreamer p2p.Streamer,\n\tstore storer.Reserve,\n\tunwrap func(swarm.Chunk),\n\tvalidStamp postage.ValidStampFn,\n\tlogger log.Logger,\n\tmaxPage uint64,\n) *Syncer\n```\n\n```go\nfunc (s *Syncer) Close() error\n```\n\n```go\nfunc (s *Syncer) GetCursors(ctx context.Context, peer swarm.Address) (retr []uint64, epoch uint64, err error)\n```\n\n```go\nfunc (s *Syncer) Metrics() []prometheus.Collector\n```\n\n```go\nfunc (s *Syncer) Protocol() p2p.ProtocolSpec\n```\n\n```go\nfunc (s *Syncer) Sync(ctx context.Context, peer swarm.Address, bin uint8, start uint64) (uint64, int, error)\n```\nSync 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.\n\n","path":"github.com/ethersphere/bee/pkg/pullsync","name":"pullsync","synopsis":"Package pullsync contains protocol that is used to ensure that there is correct chunk replication in the neighborhood of the node.","isRedistributable":true}
