peerresponsemanager

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator added in v0.4.0

type Allocator interface {
	AllocateBlockMemory(p peer.ID, amount uint64) <-chan error
	ReleasePeerMemory(p peer.ID) error
	ReleaseBlockMemory(p peer.ID, amount uint64) error
}

Allocator is an interface that can manage memory allocated for blocks

type Event added in v0.3.0

type Event struct {
	Name EventName
	Err  error
}

Event is an event that is published by the peer response sender

type EventName added in v0.3.0

type EventName uint64

EventName is a type of event that is published by the peer response sender

const (
	// Sent indicates the item was sent over the wire
	Sent EventName = iota
	// Error indicates an error sending an item
	Error
)

type PeerMessageHandler

type PeerMessageHandler interface {
	SendResponse(peer.ID, []gsmsg.GraphSyncResponse, []blocks.Block, ...notifications.Notifee)
}

PeerMessageHandler is an interface that can send a response for a given peer across the network.

type PeerResponseManager

type PeerResponseManager struct {
	*peermanager.PeerManager
}

PeerResponseManager manages message queues for peers

func New

func New(ctx context.Context, createPeerSender PeerSenderFactory) *PeerResponseManager

New generates a new peer manager for sending responses

func (*PeerResponseManager) SenderForPeer

func (prm *PeerResponseManager) SenderForPeer(p peer.ID) PeerResponseSender

SenderForPeer returns a response sender to use with the given peer

type PeerResponseSender

type PeerResponseSender interface {
	peermanager.PeerProcess
	DedupKey(requestID graphsync.RequestID, key string)
	IgnoreBlocks(requestID graphsync.RequestID, links []ipld.Link)
	SendResponse(
		requestID graphsync.RequestID,
		link ipld.Link,
		data []byte,
		notifees ...notifications.Notifee,
	) graphsync.BlockData
	SendExtensionData(graphsync.RequestID, graphsync.ExtensionData, ...notifications.Notifee)
	FinishWithCancel(requestID graphsync.RequestID)
	FinishRequest(requestID graphsync.RequestID, notifees ...notifications.Notifee) graphsync.ResponseStatusCode
	FinishWithError(requestID graphsync.RequestID, status graphsync.ResponseStatusCode, notifees ...notifications.Notifee)
	// Transaction calls multiple operations at once so they end up in a single response
	// Note: if the transaction function errors, the results will not execute
	Transaction(requestID graphsync.RequestID, transaction Transaction) error
	PauseRequest(requestID graphsync.RequestID, notifees ...notifications.Notifee)
}

PeerResponseSender handles batching, deduping, and sending responses for a given peer across multiple requests.

func NewResponseSender

func NewResponseSender(ctx context.Context, p peer.ID, peerHandler PeerMessageHandler, allocator Allocator) PeerResponseSender

NewResponseSender generates a new PeerResponseSender for the given context, peer ID, using the given peer message handler.

type PeerResponseTransactionSender added in v0.1.0

type PeerResponseTransactionSender interface {
	SendResponse(
		link ipld.Link,
		data []byte,
	) graphsync.BlockData
	SendExtensionData(graphsync.ExtensionData)
	FinishWithCancel()
	FinishRequest() graphsync.ResponseStatusCode
	FinishWithError(status graphsync.ResponseStatusCode)
	PauseRequest()
	AddNotifee(notifications.Notifee)
}

PeerResponseTransactionSender is a limited interface for sending responses inside a transaction

type PeerSenderFactory

type PeerSenderFactory func(ctx context.Context, p peer.ID) PeerResponseSender

PeerSenderFactory provides a function that will create a PeerResponseSender.

type Transaction added in v0.1.0

type Transaction func(PeerResponseTransactionSender) error

Transaction is a series of operations that should be send together in a single response

Jump to

Keyboard shortcuts

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