p2p

package
v0.0.0-...-4d9f4f2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 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()

	// Broadcast broadcasts the given message to all the neighboring peers
	Broadcast(message types.Message) chan bool

	// BroadcastToNeighbors broadcasts the given message to the neighboring peers
	BroadcastToNeighbors(message types.Message, maxNumPeersToBroadcast int) 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() []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
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.
Package nat implements NAT handling facilities
Package nat implements NAT handling facilities
Taken from taipei-torrent Just enough UPnP to be able to forward ports
Taken from taipei-torrent Just enough UPnP to be able to forward ports

Jump to

Keyboard shortcuts

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