mock

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 9 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 boson.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(addr ...boson.Address)

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

func (*Mock) Announce

func (m *Mock) Announce(_ context.Context, _ boson.Address, _ bool) error

func (*Mock) AnnounceTo

func (m *Mock) AnnounceTo(_ context.Context, _, _ boson.Address, _ bool) error

func (*Mock) Close

func (m *Mock) Close() error

func (*Mock) ClosestPeer

func (m *Mock) ClosestPeer(addr boson.Address, _ bool, _ topology.Filter, skipPeers ...boson.Address) (peerAddr boson.Address, err error)

func (*Mock) ClosestPeers

func (m *Mock) ClosestPeers(addr boson.Address, limit int, _ topology.Filter, skipPeers ...boson.Address) ([]boson.Address, error)

func (*Mock) Connected

func (m *Mock) Connected(_ context.Context, peer p2p.Peer, _ bool) error

Connected is called when a peer dials in.

func (*Mock) DisconnectForce

func (m *Mock) DisconnectForce(addr boson.Address, reason string) error

func (*Mock) Disconnected

func (m *Mock) Disconnected(peer p2p.Peer, reason string)

Disconnected is called when a peer disconnects.

func (*Mock) EachKnownPeer

func (m *Mock) EachKnownPeer(peerFunc model.EachPeerFunc) error

func (*Mock) EachKnownPeerRev

func (m *Mock) EachKnownPeerRev(peerFunc model.EachPeerFunc) error

func (*Mock) EachNeighbor

func (m *Mock) EachNeighbor(model.EachPeerFunc) error

func (*Mock) EachNeighborRev

func (m *Mock) EachNeighborRev(model.EachPeerFunc) error

func (*Mock) EachPeer

func (m *Mock) EachPeer(f model.EachPeerFunc, _ topology.Filter) error

EachPeer iterates from closest bin to farthest

func (*Mock) EachPeerRev

func (m *Mock) EachPeerRev(f model.EachPeerFunc, _ topology.Filter) error

EachPeerRev iterates from farthest bin to closest

func (*Mock) GetPeersWithLatencyEWMA added in v1.4.1

func (m *Mock) GetPeersWithLatencyEWMA(list []boson.Address) (now []boson.Address)

func (*Mock) Halt

func (m *Mock) Halt()

func (*Mock) IsWithinDepth

func (m *Mock) IsWithinDepth(_ boson.Address) bool

func (*Mock) NeighborhoodDepth

func (m *Mock) NeighborhoodDepth() uint8

func (*Mock) NotifyPeerState

func (m *Mock) NotifyPeerState(peer p2p.PeerInfo)

func (*Mock) Outbound

func (m *Mock) Outbound(peer p2p.Peer)

func (*Mock) RecordPeerLatency

func (m *Mock) RecordPeerLatency(add boson.Address, t time.Duration)

func (*Mock) RefreshProtectPeer

func (m *Mock) RefreshProtectPeer(peer []boson.Address)

func (*Mock) ResetPeers

func (m *Mock) ResetPeers()

func (*Mock) Snapshot

func (m *Mock) Snapshot() *model.KadParams

func (*Mock) SnapshotAddr

func (m *Mock) SnapshotAddr(addr boson.Address) *model.Snapshot

func (*Mock) SnapshotConnected

func (m *Mock) SnapshotConnected() (connected int, peers map[string]*model.PeerInfo)

func (*Mock) SubscribePeerState

func (m *Mock) SubscribePeerState(notifier subscribe.INotifier)

func (*Mock) SubscribePeersChange

func (m *Mock) SubscribePeersChange(notifier subscribe.INotifier)

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