Documentation
¶
Index ¶
- type Clock
- type ClockController
- type FilterFunc
- type HostFactory
- type HostSlice
- type MapFunc
- type Maybe
- type Op
- type OpFunc
- type Option
- type SelectFunc
- type Simulation
- func (s Simulation) Clock() Clock
- func (s Simulation) MustHost(ctx context.Context, opt ...config.Option) host.Host
- func (s Simulation) MustHostSet(ctx context.Context, n int, opt ...config.Option) HostSlice
- func (s Simulation) NewDiscovery(h host.Host, t netsim.Topology) *netsim.DiscoveryService
- func (s Simulation) NewHost(ctx context.Context, opt ...config.Option) (host.Host, error)
- func (s Simulation) NewHostSet(ctx context.Context, n int, opt ...config.Option) (HostSlice, error)
- func (s Simulation) Op(ops ...OpFunc) Op
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClockController ¶
type FilterFunc ¶
func SelectIDs ¶
func SelectIDs(ids ...peer.ID) FilterFunc
func SelectIndex ¶
func SelectIndex(i int) FilterFunc
type HostFactory ¶
type OpFunc ¶
type OpFunc func(s Simulation) func(ctx context.Context) Maybe
func Filter ¶
func Filter(f FilterFunc) OpFunc
func Select ¶
func Select(f SelectFunc) OpFunc
type Option ¶
type Option func(sim *Simulation)
func WithClock ¶
func WithClock(c ClockController) Option
WithClock sets the simulation clock. If c == nil, a default clock with 10ms accuracy is used.
func WithHostFactory ¶
func WithHostFactory(f HostFactory) Option
WithHostFactory sets the host factory for the simulation. If f == nil, a default factory is used that constructs hosts using an in-process transport.
func WithNamespaceFactory ¶
func WithNamespaceFactory(f func(Clock) netsim.NamespaceProvider) Option
WithNamespaceFactory sets the namespace implementation for the simulation. If ns == nil, a default namespace implementation is used.
type SelectFunc ¶
type Simulation ¶
type Simulation struct {
// contains filtered or unexported fields
}
func (Simulation) Clock ¶
func (s Simulation) Clock() Clock
func (Simulation) MustHostSet ¶
MustHostSet calls NewHostSet with the supplied parameters and panics if an error is encountered.
func (Simulation) NewDiscovery ¶
func (s Simulation) NewDiscovery(h host.Host, t netsim.Topology) *netsim.DiscoveryService
NewDiscovery returns a discovery.Discovery implementation that supports the Simulation's in-process network.
The topology parameter t can be used to specify an initial connection topology. All peers must use the same instance of t in order to obtain the desired topology.
If t == nil, the topology defaults to netsim.SelectAll.
func (Simulation) NewHost ¶
NewHost assembles and creates a new libp2p host that uses the simulation's network.
The simulation configures hosts to use an in-process network, overriding the following options:
- libp2p.Transport - libp2p.NoTransports - libp2p.ListenAddr - libp2p.ListenAddrStrings - libp2p.NoListenAddrs
Users SHOULD NOT pass any of the above options to NewHost.
func (Simulation) NewHostSet ¶
NewHostSet builds and configures n hosts with identical parameters.
See NewHost.
func (Simulation) Op ¶
func (s Simulation) Op(ops ...OpFunc) Op