p2pl

package
v0.6.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageHandler

type MessageHandler interface {

	// GetChannelIDs returns the list channelIDs that the message handler needs to handle
	GetChannelIDs() []common.ChannelIDEnum

	// ParseMessage parses the raw message bytes
	ParseMessage(peerID string, channelID common.ChannelIDEnum, rawMessageBytes common.Bytes) (types.Message, error)

	// EncodeMessage encodes message to bytes
	EncodeMessage(message interface{}) (common.Bytes, error)

	// HandleMessage processes the received message
	HandleMessage(message types.Message) error
}

MessageHandler interface

type Network

type Network interface {

	// Start is called when the network starts
	Start(ctx context.Context) error

	// Wait blocks until all goroutines have stopped
	Wait()

	// Stop is called when the network stops
	Stop()

	// Publish publishes the given message to all the subscribers
	Publish(message types.Message) error

	// Broadcast publishes the given message
	Broadcast(message types.Message, skipEdgeNode bool) chan bool

	// BroadcastToNeighbors broadcasts the given message to the neighboring peers
	BroadcastToNeighbors(message types.Message, maxNumPeersToBroadcast int, skipEdgeNode bool) chan bool

	// Send sends the given message to the peer specified by the peerID
	Send(peerID string, message types.Message) bool

	// Peers return the IDs of all peers
	Peers(skipEdgeNode bool) []string

	// PeerURLs return the URLs of all peers
	PeerURLs(skipEdgeNode bool) []string

	// PeerExists indicates if the given peerID is a neighboring peer
	PeerExists(peerID string) bool

	// RegisterMessageHandler registers message handler
	RegisterMessageHandler(messageHandler MessageHandler)

	// ID returns the ID of the network peer
	ID() string
}

Network is a handle to the P2P network

Directories

Path Synopsis
buffer/flowrate
Package flowrate provides the tools for monitoring and limiting the flow rate of an arbitrary data stream.
Package flowrate provides the tools for monitoring and limiting the flow rate of an arbitrary data stream.

Jump to

Keyboard shortcuts

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