netsim

package
v1.0.0-alpha.18 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL = time.Hour * 24

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoveryService

type DiscoveryService struct {
	NS   NamespaceProvider
	Info *peer.AddrInfo
	Topo Topology
	// contains filtered or unexported fields
}

func (*DiscoveryService) Advertise

func (d *DiscoveryService) Advertise(ctx context.Context, ns string, opt ...discovery.Option) (time.Duration, error)

func (*DiscoveryService) FindPeers

func (d *DiscoveryService) FindPeers(ctx context.Context, ns string, opt ...discovery.Option) (<-chan peer.AddrInfo, error)

type HostFactory

type HostFactory struct {
	inproc.Env
	// contains filtered or unexported fields
}

func (*HostFactory) NewHost

func (f *HostFactory) NewHost(ctx context.Context, opt []config.Option) (host.Host, error)

NewHost assembles and creates a new libp2p host that uses the simulation's network.

Env configures hosts to use an in-process network and therefore overrides the following options:

- libp2p.Transport - libp2p.NoTransports - libp2p.ListenAddr - libp2p.ListenAddrStrings - libp2p.NoListenAddrs

Users SHOULD NOT pass any of the above options to NewHost.

type InfoSlice

type InfoSlice []*peer.AddrInfo

func (InfoSlice) Filter

func (is InfoSlice) Filter(f func(info *peer.AddrInfo) bool) InfoSlice

func (InfoSlice) Len

func (is InfoSlice) Len() int

func (InfoSlice) Less

func (is InfoSlice) Less(i, j int) bool

func (InfoSlice) Swap

func (is InfoSlice) Swap(i, j int)

type NamespaceProvider

type NamespaceProvider interface {
	LoadOrCreate(string) Scope
	Load(string) (Scope, bool)
}

type Scope

type Scope interface {
	Peers() InfoSlice
	Upsert(*peer.AddrInfo, *discovery.Options) time.Duration
}

type SelectAll

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

func (SelectAll) Select

func (t SelectAll) Select(_ context.Context, s Scope, local *peer.AddrInfo, opts *discovery.Options) (InfoSlice, error)

func (SelectAll) SetDefaultOptions

func (SelectAll) SetDefaultOptions(opts *discovery.Options) error

Implementations that embed SelectAll SHOULD call SelectAll.SetDefaultOptions before modifying the opts.

type SelectRandom

type SelectRandom struct {
	Src rand.Source

	SelectAll
	// contains filtered or unexported fields
}

func (*SelectRandom) Select

func (t *SelectRandom) Select(_ context.Context, s Scope, local *peer.AddrInfo, opts *discovery.Options) (InfoSlice, error)

type SelectRing

type SelectRing struct{ SelectAll }

func (SelectRing) Select

func (t SelectRing) Select(ctx context.Context, s Scope, local *peer.AddrInfo, opts *discovery.Options) (InfoSlice, error)

type Topology

type Topology interface {
	SetDefaultOptions(*discovery.Options) error
	Select(context.Context, Scope, *peer.AddrInfo, *discovery.Options) (InfoSlice, error)
}

Topology selects peeers from the environment.

Jump to

Keyboard shortcuts

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