Help us shape the future of Go! Take the 2026 Go Developer Survey

p2p

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// SetAsideForConsensus set the number of active validation goroutines for the consensus topic
	SetAsideForConsensus = 1 << 13
	// SetAsideOtherwise set the number of active validation goroutines for other topic
	SetAsideOtherwise = 1 << 11
	// MaxMessageHandlers ..
	MaxMessageHandlers = SetAsideForConsensus + SetAsideOtherwise
	// MaxMessageSize is 2Mb
	MaxMessageSize = 1 << 21
)

Variables

This section is empty.

Functions

func ConstructMessage added in v1.3.8

func ConstructMessage(content []byte) []byte

ConstructMessage constructs the p2p message as [messageType, contentSize, content]

func StringsToAddrs added in v1.3.8

func StringsToAddrs(addrStrings []string) (maddrs []ma.Multiaddr, err error)

StringsToAddrs convert a list of strings to a list of multiaddresses

Types

type AddrList added in v1.3.8

type AddrList []ma.Multiaddr

AddrList is a list of multiaddress

var BootNodes AddrList

BootNodes is a list of boot nodes. It is populated either from default or from user CLI input. TODO: refactor p2p config into a config structure (now part of config is here, part is in

nodeconfig)

func (*AddrList) Set added in v1.3.8

func (al *AddrList) Set(value string) error

Set is a function to set the value of AddrList based on a string

func (*AddrList) String added in v1.3.8

func (al *AddrList) String() string

String is a function to print a string representation of the AddrList

type Host

type Host interface {
	GetSelfPeer() Peer
	AddPeer(*Peer) error
	GetID() libp2p_peer.ID
	GetP2PHost() libp2p_host.Host
	GetPeerCount() int
	ConnectHostPeer(Peer) error
	// SendMessageToGroups sends a message to one or more multicast groups.
	SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) error
	PubSub() *libp2p_pubsub.PubSub
	C() (int, int, int)
	GetOrJoin(topic string) (*libp2p_pubsub.Topic, error)
	ListPeer(topic string) []libp2p_peer.ID
	ListTopic() []string
	ListBlockedPeer() []libp2p_peer.ID
}

Host is the client + server in p2p network.

func NewHost added in v1.3.8

func NewHost(self *Peer, key libp2p_crypto.PrivKey) (Host, error)

NewHost ..

type HostV2 added in v1.3.8

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

HostV2 is the version 2 p2p host

func (*HostV2) AddPeer added in v1.3.8

func (host *HostV2) AddPeer(p *Peer) error

AddPeer add p2p.Peer into Peerstore

func (*HostV2) C added in v1.3.11

func (host *HostV2) C() (int, int, int)

C .. -> (total known peers, connected, not connected)

func (*HostV2) ConnectHostPeer added in v1.3.8

func (host *HostV2) ConnectHostPeer(peer Peer) error

ConnectHostPeer connects to peer host

func (*HostV2) GetID added in v1.3.8

func (host *HostV2) GetID() libp2p_peer.ID

GetID returns ID.Pretty

func (*HostV2) GetOrJoin added in v1.10.0

func (host *HostV2) GetOrJoin(topic string) (*libp2p_pubsub.Topic, error)

GetOrJoin ..

func (*HostV2) GetP2PHost added in v1.3.8

func (host *HostV2) GetP2PHost() libp2p_host.Host

GetP2PHost returns the p2p.Host

func (*HostV2) GetPeerCount added in v1.3.8

func (host *HostV2) GetPeerCount() int

GetPeerCount ...

func (*HostV2) GetSelfPeer added in v1.3.8

func (host *HostV2) GetSelfPeer() Peer

GetSelfPeer gets self peer

func (*HostV2) ListBlockedPeer added in v1.10.0

func (host *HostV2) ListBlockedPeer() []libp2p_peer.ID

ListBlockedPeer returns list of blocked peer

func (*HostV2) ListPeer added in v1.10.0

func (host *HostV2) ListPeer(topic string) []libp2p_peer.ID

ListPeer returns list of peers in a topic

func (*HostV2) ListTopic added in v1.10.0

func (host *HostV2) ListTopic() []string

ListTopic returns the list of topic the node subscribed

func (*HostV2) Peerstore added in v1.3.8

func (host *HostV2) Peerstore() libp2p_peerstore.Peerstore

Peerstore returns the peer store

func (*HostV2) PubSub added in v1.10.0

func (host *HostV2) PubSub() *libp2p_pubsub.PubSub

PubSub ..

func (*HostV2) SendMessageToGroups added in v1.3.8

func (host *HostV2) SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) (err error)

SendMessageToGroups sends a message to one or more multicast groups. It returns a nil error if and only if it has succeeded to schedule the given message for sending.

type NamedTopic added in v1.10.0

type NamedTopic struct {
	Name  string
	Topic *libp2p_pubsub.Topic
}

NamedTopic represents pubsub topic Name is the human readable topic, groupID

type Peer

type Peer struct {
	IP              string         // IP address of the peer
	Port            string         // Port number of the peer
	ConsensusPubKey *bls.PublicKey // Public key of the peer, used for consensus signing
	Addrs           []ma.Multiaddr // MultiAddress of the peer
	PeerID          libp2p_peer.ID // PeerID, the pubkey for communication
}

Peer is the object for a p2p peer (node)

Jump to

Keyboard shortcuts

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