hostv2

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BatchSizeInByte The batch size in byte (64MB) in which we return data
	BatchSizeInByte = 1 << 16
	// ProtocolID The ID of protocol used in stream handling.
	ProtocolID = "/harmony/0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupReceiverImpl

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

GroupReceiverImpl is a multicast group receiver implementation.

func (*GroupReceiverImpl) Close

func (r *GroupReceiverImpl) Close() error

Close closes this receiver.

func (*GroupReceiverImpl) Receive

func (r *GroupReceiverImpl) Receive(ctx context.Context) (
	msg []byte, sender libp2p_peer.ID, err error,
)

Receive receives a message.

type HostV2

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

HostV2 is the version 2 p2p host

func New

func New(self *p2p.Peer, priKey libp2p_crypto.PrivKey) (*HostV2, error)

New creates a host for p2p communication

func (*HostV2) AddPeer

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

AddPeer add p2p.Peer into Peerstore

func (*HostV2) Close

func (host *HostV2) Close() error

Close closes the host

func (*HostV2) ConnectHostPeer

func (host *HostV2) ConnectHostPeer(peer p2p.Peer)

ConnectHostPeer connects to peer host

func (*HostV2) GetID

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

GetID returns ID.Pretty

func (*HostV2) GetP2PHost

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

GetP2PHost returns the p2p.Host

func (*HostV2) GetPeerCount

func (host *HostV2) GetPeerCount() int

GetPeerCount ...

func (*HostV2) GetSelfPeer

func (host *HostV2) GetSelfPeer() p2p.Peer

GetSelfPeer gets self peer

func (*HostV2) GroupReceiver

func (host *HostV2) GroupReceiver(group nodeconfig.GroupID) (
	receiver p2p.GroupReceiver, err error,
)

GroupReceiver returns a receiver of messages sent to a multicast group. See the GroupReceiver interface for details.

func (*HostV2) Peerstore

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

Peerstore returns the peer store

func (*HostV2) SendMessageToGroups

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.

Jump to

Keyboard shortcuts

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