firsthop

package
v2.8.4-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package firsthop keeps the results of the first hops of an origin.

An origin sends a chunk to one of its peers, the first hop, and gets back a receipt that is valid (the chunk was stored inside its neighborhood) or shallow (it was stored outside of it), or an error. The Memory keeps the last result of each first hop per neighborhood, so that the next chunk of the neighborhood goes to a first hop that gave a valid receipt and not to one that gave a shallow receipt or an error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory keeps the last result of each first hop per neighborhood. It holds the records of one radius at a time. It is safe for concurrent use.

func New

func New(now func() time.Time) *Memory

New returns an empty memory that reads the time from now.

func (*Memory) ClaimProbe

func (m *Memory) ClaimProbe(radius uint8, chunk swarm.Address) bool

ClaimProbe reports whether a probe of the neighborhood of the chunk is due, and stores the time of the probe when it is. Of the callers that run at the same time, only one gets true.

func (*Memory) Forget

func (m *Memory) Forget(radius uint8, chunk, peer swarm.Address)

Forget removes the record of the peer, except a record whose pause still runs.

func (*Memory) Pause

func (m *Memory) Pause(radius uint8, chunk, peer swarm.Address)

Pause starts a pause of the peer after a shallow receipt or an error. A result that comes during the pause does not make the pause longer.

func (*Memory) Size

func (m *Memory) Size() (neighborhoods, records int)

Size returns the number of neighborhoods and the number of records.

func (*Memory) Valid

func (m *Memory) Valid(radius uint8, chunk, peer swarm.Address)

Valid stores a valid receipt of the peer.

func (*Memory) View

func (m *Memory) View(radius uint8, chunk swarm.Address) View

View returns the records of the neighborhood of the chunk. The radius of the call becomes the radius of the memory: the records of another radius are removed.

type View

type View struct {
	// Valid are the peers whose last receipt was valid.
	Valid []swarm.Address
	// Paused are the peers in a pause; the pause that ends first
	// comes first.
	Paused []swarm.Address
	// ProbeDue is true when the neighborhood had no probe for the probe interval.
	ProbeDue bool
}

View is what the memory holds about the first hops of one neighborhood.

Jump to

Keyboard shortcuts

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