dispatcher

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MaxInventorySize = 50

MaxInventorySize defines the max number of items in InventoryRequest/InventoryResponse.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataRequest

type DataRequest struct {
	ChannelID common.ChannelIDEnum
	Entries   []string
}

DataRequest defines the structure of the data request

type DataResponse

type DataResponse struct {
	ChannelID common.ChannelIDEnum
	Payload   common.Bytes
}

DataResponse defines the structure of the data response

type Dispatcher

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

Dispatcher dispatches messages to approporiate destinations

func NewDispatcher

func NewDispatcher(p2pnet p2p.Network, p2plnet p2pl.Network) *Dispatcher

NewLDispatcher returns the pointer to the Dispatcher singleton

func (*Dispatcher) GetData

func (dp *Dispatcher) GetData(peerIDs []string, datareq DataRequest)

GetData sends out the DataRequest

func (*Dispatcher) GetInventory

func (dp *Dispatcher) GetInventory(peerIDs []string, invreq InventoryRequest)

GetInventory sends out the InventoryRequest

func (Dispatcher) ID

func (dp Dispatcher) ID() string

ID returns the ID of the node

func (Dispatcher) LibP2PID

func (dp Dispatcher) LibP2PID() string

TODO: for 1.3.0 upgrade only, delete it after the upgrade completed ID returns the ID of the node

func (*Dispatcher) PeerExists

func (dp *Dispatcher) PeerExists(peerID string) bool

PeerExists indicates if the given peerID is a neighboring peer

func (*Dispatcher) Peers

func (dp *Dispatcher) Peers() []string

Peers returns the IDs of all peers

func (*Dispatcher) SendData

func (dp *Dispatcher) SendData(peerIDs []string, datarsp DataResponse)

SendData sends out the DataResponse

func (*Dispatcher) SendInventory

func (dp *Dispatcher) SendInventory(peerIDs []string, invrsp InventoryResponse)

SendInventory sends out the InventoryResponse

func (*Dispatcher) Start

func (dp *Dispatcher) Start(ctx context.Context) error

Start is called when the dispatcher starts

func (*Dispatcher) Stop

func (dp *Dispatcher) Stop()

Stop is called when the dispatcher stops

func (*Dispatcher) Wait

func (dp *Dispatcher) Wait()

Wait suspends the caller goroutine

type InventoryRequest

type InventoryRequest struct {
	ChannelID common.ChannelIDEnum
	Starts    []string // Starting hashes.
	End       string   // Optional ending hash.
}

InventoryRequest defines the structure of the inventory request

type InventoryResponse

type InventoryResponse struct {
	ChannelID common.ChannelIDEnum
	Entries   []string
}

InventoryResponse defines the structure of the inventory response

Jump to

Keyboard shortcuts

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