mock

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrTuple

type AddrTuple struct {
	Addr swarm.Address // the peer address
	PO   uint8         // the po
}

type Mock

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

func NewMockKademlia

func NewMockKademlia(o ...Option) *Mock

func (*Mock) AddPeers

func (m *Mock) AddPeers(ctx context.Context, addr ...swarm.Address) error

AddPeers is called when a peers are added to the topology backlog for further processing by connectivity strategy.

func (*Mock) Close

func (m *Mock) Close() error

func (*Mock) ClosestPeer

func (m *Mock) ClosestPeer(addr swarm.Address, skipPeers ...swarm.Address) (peerAddr swarm.Address, err error)

func (*Mock) Connected

func (m *Mock) Connected(_ context.Context, addr swarm.Address) error

Connected is called when a peer dials in.

func (*Mock) Disconnected

func (m *Mock) Disconnected(_ swarm.Address)

Disconnected is called when a peer disconnects.

func (*Mock) EachPeer

func (m *Mock) EachPeer(f topology.EachPeerFunc) error

EachPeer iterates from closest bin to farthest

func (*Mock) EachPeerRev

func (m *Mock) EachPeerRev(f topology.EachPeerFunc) error

EachPeerRev iterates from farthest bin to closest

func (*Mock) NeighborhoodDepth

func (m *Mock) NeighborhoodDepth() uint8

func (*Mock) ResetPeers

func (m *Mock) ResetPeers()

func (*Mock) SubscribePeersChange

func (m *Mock) SubscribePeersChange() (c <-chan struct{}, unsubscribe func())

func (*Mock) Trigger

func (m *Mock) Trigger()

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithDepth

func WithDepth(d uint8) Option

func WithDepthCalls

func WithDepthCalls(d ...uint8) Option

func WithEachPeerRevCalls

func WithEachPeerRevCalls(addrs ...AddrTuple) Option

Jump to

Keyboard shortcuts

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