Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventName ¶ added in v0.3.0
type EventName uint64
EventName is a type of event that is published by the peer response sender
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) 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