pslice

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PSlice

type PSlice struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PSlice maintains a list of addresses, indexing them by their different proximity orders. Currently, when peers are added or removed, their proximity order must be supplied, this is in order to reduce duplicate PO calculation which is normally known and already needed in the calling context.

func New

func New(maxBins int) *PSlice

New creates a new PSlice.

func (*PSlice) Add

func (s *PSlice) Add(addr swarm.Address, po uint8)

Add a peer at a certain PO.

func (*PSlice) EachBin

func (s *PSlice) EachBin(pf topology.EachPeerFunc) error

iterates over all peers from deepest bin to shallowest.

func (*PSlice) EachBinRev

func (s *PSlice) EachBinRev(pf topology.EachPeerFunc) error

EachBinRev iterates over all peers from shallowest bin to deepest.

func (*PSlice) Exists

func (s *PSlice) Exists(addr swarm.Address) bool

Exists checks if a peer exists.

func (*PSlice) Length

func (s *PSlice) Length() int

func (*PSlice) Remove

func (s *PSlice) Remove(addr swarm.Address, po uint8)

Remove a peer at a certain PO.

func (*PSlice) ShallowestEmpty

func (s *PSlice) ShallowestEmpty() (bin uint8, none bool)

ShallowestEmpty returns the shallowest empty bin if one exists. If such bin does not exists, returns true as bool value.

Jump to

Keyboard shortcuts

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