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 ¶
- type Memory
- func (m *Memory) ClaimProbe(radius uint8, chunk swarm.Address) bool
- func (m *Memory) Forget(radius uint8, chunk, peer swarm.Address)
- func (m *Memory) Pause(radius uint8, chunk, peer swarm.Address)
- func (m *Memory) Size() (neighborhoods, records int)
- func (m *Memory) Valid(radius uint8, chunk, peer swarm.Address)
- func (m *Memory) View(radius uint8, chunk swarm.Address) View
- type View
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 (*Memory) ClaimProbe ¶
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 ¶
Forget removes the record of the peer, except a record whose pause still runs.
func (*Memory) Pause ¶
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.
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.