p2p

package
v1.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrInfo

type AddrInfo struct {
	Info
	Addrs []p2p.Multiaddr `json:"addrs,omitempty" form:"addrs" query:"addrs" validate:"required"`
	// contains filtered or unexported fields
}

func (*AddrInfo) Copy

func (v *AddrInfo) Copy() *AddrInfo

func (*AddrInfo) CopyAsInterface

func (v *AddrInfo) CopyAsInterface() interface{}

func (*AddrInfo) Equal

func (v *AddrInfo) Equal(u *AddrInfo) bool

func (*AddrInfo) IsValid

func (v *AddrInfo) IsValid() error

func (*AddrInfo) MarshalBinary

func (v *AddrInfo) MarshalBinary() ([]byte, error)

func (*AddrInfo) MarshalJSON

func (v *AddrInfo) MarshalJSON() ([]byte, error)

func (*AddrInfo) UnmarshalBinary

func (v *AddrInfo) UnmarshalBinary(data []byte) error

func (*AddrInfo) UnmarshalBinaryFrom

func (v *AddrInfo) UnmarshalBinaryFrom(rd io.Reader) error

func (*AddrInfo) UnmarshalJSON

func (v *AddrInfo) UnmarshalJSON(data []byte) error

type Info

type Info struct {
	ID       p2p.PeerID     `json:"id,omitempty" form:"id" query:"id" validate:"required"`
	Services []*ServiceInfo `json:"services,omitempty" form:"services" query:"services" validate:"required"`
	// contains filtered or unexported fields
}

func (*Info) Copy

func (v *Info) Copy() *Info

func (*Info) CopyAsInterface

func (v *Info) CopyAsInterface() interface{}

func (*Info) Equal

func (v *Info) Equal(u *Info) bool

func (*Info) HasService

func (i *Info) HasService(service *api.ServiceAddress) bool

HasService returns true if Info includes the given Service.

func (*Info) IsValid

func (v *Info) IsValid() error

func (*Info) MarshalBinary

func (v *Info) MarshalBinary() ([]byte, error)

func (*Info) MarshalJSON

func (v *Info) MarshalJSON() ([]byte, error)

func (*Info) UnmarshalBinary

func (v *Info) UnmarshalBinary(data []byte) error

func (*Info) UnmarshalBinaryFrom

func (v *Info) UnmarshalBinaryFrom(rd io.Reader) error

func (*Info) UnmarshalJSON

func (v *Info) UnmarshalJSON(data []byte) error

type MessageStreamHandler

type MessageStreamHandler func(message.Stream)

A MessageStreamHandler handles an incoming message.Stream.

type Node

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

Node implements peer-to-peer routing of API v3 messages over via binary message transport.

func New

func New(opts Options) (_ *Node, err error)

New creates a node with the given Options.

func (*Node) Addrs

func (n *Node) Addrs() []multiaddr.Multiaddr

Addrs lists the node's addresses.

func (*Node) Close

func (n *Node) Close() error

Close shuts down the host and topics.

func (*Node) ConnectDirectly

func (n *Node) ConnectDirectly(m *Node) error

ConnectDirectly connects this node directly to another node.

func (*Node) Dialer

func (n *Node) Dialer() message.MultiDialer

Dialer returns a message.MultiDialer that knows how to dial any partition or node in the network.

func (*Node) ID

func (n *Node) ID() peer.ID

func (*Node) Peers

func (n *Node) Peers() []*Info

Peers lists the node's known peers.

func (*Node) RegisterService

func (n *Node) RegisterService(sa *api.ServiceAddress, handler MessageStreamHandler) bool

RegisterService registers a service handler.

func (*Node) SelfDialer

func (n *Node) SelfDialer() message.Dialer

SelfDialer returns a message.Dialer that always returns a stream for the current node.

func (*Node) WaitForService

func (s *Node) WaitForService(sa *api.ServiceAddress)

WaitForService blocks until the given service is available. WaitForService will return once the service is registered on the current node or until the node is informed of a peer with the given service. WaitForService will return immediately if the service is already registered or known.

type Options

type Options struct {
	Logger log.Logger

	// Listen is an array of addresses to listen on.
	Listen []multiaddr.Multiaddr

	// BootstrapPeers is an array of addresses of the bootstrap peers to connect
	// to on bootup.
	BootstrapPeers []multiaddr.Multiaddr

	// Key is the node's private key. If Key is omitted, the node will
	// generate a new key.
	Key ed25519.PrivateKey
}

Options are options for creating a Node.

type PartitionOptions

type PartitionOptions struct {
	// ID is the ID of the partition.
	ID string

	// Moniker is the Tendermint node's moniker.
	Moniker string
}

PartitionOptions defines a Node's involvement in a partition.

type ServiceInfo

type ServiceInfo struct {
	Address *api.ServiceAddress `json:"address,omitempty" form:"address" query:"address" validate:"required"`
	// contains filtered or unexported fields
}

func (*ServiceInfo) Copy

func (v *ServiceInfo) Copy() *ServiceInfo

func (*ServiceInfo) CopyAsInterface

func (v *ServiceInfo) CopyAsInterface() interface{}

func (*ServiceInfo) Equal

func (v *ServiceInfo) Equal(u *ServiceInfo) bool

func (*ServiceInfo) IsValid

func (v *ServiceInfo) IsValid() error

func (*ServiceInfo) MarshalBinary

func (v *ServiceInfo) MarshalBinary() ([]byte, error)

func (*ServiceInfo) UnmarshalBinary

func (v *ServiceInfo) UnmarshalBinary(data []byte) error

func (*ServiceInfo) UnmarshalBinaryFrom

func (v *ServiceInfo) UnmarshalBinaryFrom(rd io.Reader) error

type Whoami

type Whoami struct {
	Self  *Info       `json:"self,omitempty" form:"self" query:"self" validate:"required"`
	Known []*AddrInfo `json:"known,omitempty" form:"known" query:"known" validate:"required"`
	// contains filtered or unexported fields
}

func (*Whoami) Copy

func (v *Whoami) Copy() *Whoami

func (*Whoami) CopyAsInterface

func (v *Whoami) CopyAsInterface() interface{}

func (*Whoami) Equal

func (v *Whoami) Equal(u *Whoami) bool

func (*Whoami) IsValid

func (v *Whoami) IsValid() error

func (*Whoami) MarshalBinary

func (v *Whoami) MarshalBinary() ([]byte, error)

func (*Whoami) MarshalJSON

func (v *Whoami) MarshalJSON() ([]byte, error)

func (*Whoami) UnmarshalBinary

func (v *Whoami) UnmarshalBinary(data []byte) error

func (*Whoami) UnmarshalBinaryFrom

func (v *Whoami) UnmarshalBinaryFrom(rd io.Reader) error

func (*Whoami) UnmarshalJSON

func (v *Whoami) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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