Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeerMessageHandler ¶
type PeerMessageHandler interface {
SendResponse(peer.ID, []gsmsg.GraphSyncResponse, []blocks.Block) <-chan struct{}
}
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
IgnoreBlocks(requestID graphsync.RequestID, links []ipld.Link)
SendResponse(
requestID graphsync.RequestID,
link ipld.Link,
data []byte,
) graphsync.BlockData
SendExtensionData(graphsync.RequestID, graphsync.ExtensionData)
FinishWithCancel(requestID graphsync.RequestID)
FinishRequest(requestID graphsync.RequestID) graphsync.ResponseStatusCode
FinishWithError(requestID graphsync.RequestID, status graphsync.ResponseStatusCode)
// 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)
}
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()
}
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