Documentation ¶
Overview ¶
package vswarm implements a virtual swarm which is capable of emulating other types of swarms.
Index ¶
- Constants
- type Option
- type Realm
- type SecureRealm
- type SecureSwarm
- func (s *SecureSwarm[A, Pub]) Ask(ctx context.Context, resp []byte, dst A, v p2p.IOVec) (int, error)
- func (s *SecureSwarm[A, Pub]) Close() error
- func (s *SecureSwarm[A, Pub]) LocalAddr() A
- func (s *SecureSwarm[A, Pub]) LocalAddrs() []A
- func (s *SecureSwarm[A, Pub]) LookupPublicKey(ctx context.Context, target A) (Pub, error)
- func (s *SecureSwarm[A, Pub]) MTU() int
- func (s *SecureSwarm[A, Pub]) ParseAddr(x []byte) (A, error)
- func (s *SecureSwarm[A, Pub]) PublicKey() Pub
- func (s *SecureSwarm[A, Pub]) Receive(ctx context.Context, fn func(p2p.Message[A])) error
- func (s *SecureSwarm[A, Pub]) ServeAsk(ctx context.Context, ...) error
- func (s *SecureSwarm[A, Pub]) Tell(ctx context.Context, dst A, v p2p.IOVec) error
- type Swarm
- func (s *Swarm[A]) Ask(ctx context.Context, resp []byte, dst A, v p2p.IOVec) (int, error)
- func (s *Swarm[A]) Close() error
- func (s *Swarm[A]) LocalAddr() A
- func (s *Swarm[A]) LocalAddrs() []A
- func (s *Swarm[A]) MTU() int
- func (s *Swarm[A]) ParseAddr(x []byte) (A, error)
- func (s *Swarm[A]) Receive(ctx context.Context, fn func(p2p.Message[A])) error
- func (s *Swarm[A]) ServeAsk(ctx context.Context, ...) error
- func (s *Swarm[A]) Tell(ctx context.Context, dst A, v p2p.IOVec) error
- type SwarmOption
Constants ¶
View Source
const ( DefaultMTU = 1 << 16 DefaultQueueLen = 2 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option[A p2p.ComparableAddr] func(*realmConfig[A])
Options are passed to New and NewSecure to configure Realms.
func WithQueueLen ¶
WithQueueLen sets the maximum length of each Node's queue for recieving messages. If l < 1 QueueLen will panic.
func WithTellTransform ¶
type Realm ¶
type Realm[A p2p.ComparableAddr] SecureRealm[A, struct{}]
func (*Realm[A]) Create ¶
func (r *Realm[A]) Create(a A, opts ...SwarmOption[A]) *Swarm[A]
type SecureRealm ¶
type SecureRealm[A p2p.ComparableAddr, Pub any] struct { // contains filtered or unexported fields }
func NewSecure ¶
func NewSecure[A p2p.ComparableAddr, Pub any](parseAddr p2p.AddrParser[A], opts ...Option[A]) *SecureRealm[A, Pub]
NewSecure creates a new SecureRealm
func (*SecureRealm[A, Pub]) Create ¶
func (r *SecureRealm[A, Pub]) Create(a A, pub Pub, opts ...SwarmOption[A]) *SecureSwarm[A, Pub]
New creates a new SecureSwarm. It returns nil if the address is in use.
func (*SecureRealm[A, Pub]) Drop ¶
func (r *SecureRealm[A, Pub]) Drop(s *SecureSwarm[A, Pub])
func (*SecureRealm[A, Pub]) Len ¶
func (r *SecureRealm[A, Pub]) Len() int
type SecureSwarm ¶
type SecureSwarm[A p2p.ComparableAddr, Pub any] struct { // contains filtered or unexported fields }
func (*SecureSwarm[A, Pub]) Close ¶
func (s *SecureSwarm[A, Pub]) Close() error
func (*SecureSwarm[A, Pub]) LocalAddr ¶
func (s *SecureSwarm[A, Pub]) LocalAddr() A
func (*SecureSwarm[A, Pub]) LocalAddrs ¶
func (s *SecureSwarm[A, Pub]) LocalAddrs() []A
func (*SecureSwarm[A, Pub]) LookupPublicKey ¶
func (s *SecureSwarm[A, Pub]) LookupPublicKey(ctx context.Context, target A) (Pub, error)
func (*SecureSwarm[A, Pub]) MTU ¶
func (s *SecureSwarm[A, Pub]) MTU() int
func (*SecureSwarm[A, Pub]) ParseAddr ¶
func (s *SecureSwarm[A, Pub]) ParseAddr(x []byte) (A, error)
func (*SecureSwarm[A, Pub]) PublicKey ¶
func (s *SecureSwarm[A, Pub]) PublicKey() Pub
func (*SecureSwarm[A, Pub]) Receive ¶
func (s *SecureSwarm[A, Pub]) Receive(ctx context.Context, fn func(p2p.Message[A])) error
type Swarm ¶
type Swarm[A p2p.ComparableAddr] SecureSwarm[A, struct{}]
func (*Swarm[A]) LocalAddrs ¶
func (s *Swarm[A]) LocalAddrs() []A
type SwarmOption ¶
type SwarmOption[A p2p.ComparableAddr] func(*swarmConfig)
Click to show internal directories.
Click to hide internal directories.