p2p

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 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

	// Send sends the given message to the peer specified by the peerID
	Send(peerID string, message types.Message) 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
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