graphsync

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0, MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(parent context.Context, network gsnet.GraphSyncNetwork,
	linkSystem ipld.LinkSystem, options ...Option) graphsync.GraphExchange

New creates a new GraphSync Exchange on the given network, and the given link loader+storer.

Types

type GraphSync

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

GraphSync is an instance of a GraphSync exchange that implements the graphsync protocol.

func (*GraphSync) Cancel

func (gs *GraphSync) Cancel(ctx context.Context, requestID graphsync.RequestID) error

Cancel cancels an in progress request or response

func (*GraphSync) Pause

func (gs *GraphSync) Pause(ctx context.Context, requestID graphsync.RequestID) error

Pause pauses an in progress request or response

func (*GraphSync) PeerState

func (gs *GraphSync) PeerState(p peer.ID) PeerState

PeerState produces insight on the current state of a given peer

func (*GraphSync) RegisterBlockSentListener

func (gs *GraphSync) RegisterBlockSentListener(listener graphsync.OnBlockSentListener) graphsync.UnregisterHookFunc

RegisterBlockSentListener adds a listener for when blocks are actually sent over the wire

func (*GraphSync) RegisterCompletedResponseListener

func (gs *GraphSync) RegisterCompletedResponseListener(listener graphsync.OnResponseCompletedListener) graphsync.UnregisterHookFunc

RegisterCompletedResponseListener adds a listener on the responder for completed responses

func (*GraphSync) RegisterIncomingBlockHook

func (gs *GraphSync) RegisterIncomingBlockHook(hook graphsync.OnIncomingBlockHook) graphsync.UnregisterHookFunc

RegisterIncomingBlockHook adds a hook that runs when a block is received and validated (put in block store)

func (*GraphSync) RegisterIncomingRequestHook

func (gs *GraphSync) RegisterIncomingRequestHook(hook graphsync.OnIncomingRequestHook) graphsync.UnregisterHookFunc

RegisterIncomingRequestHook adds a hook that runs when a request is received If overrideDefaultValidation is set to true, then if the hook does not error, it is considered to have "validated" the request -- and that validation supersedes the normal validation of requests Graphsync does (i.e. all selectors can be accepted)

func (*GraphSync) RegisterIncomingRequestProcessingListener

func (gs *GraphSync) RegisterIncomingRequestProcessingListener(listener graphsync.OnRequestProcessingListener) graphsync.UnregisterHookFunc

RegisterIncomingRequestQueuedHook adds a hook that runs when a new incoming request is added to the responder's task queue.

func (*GraphSync) RegisterIncomingResponseHook

func (gs *GraphSync) RegisterIncomingResponseHook(hook graphsync.OnIncomingResponseHook) graphsync.UnregisterHookFunc

RegisterIncomingResponseHook adds a hook that runs when a response is received

func (*GraphSync) RegisterNetworkErrorListener

func (gs *GraphSync) RegisterNetworkErrorListener(listener graphsync.OnNetworkErrorListener) graphsync.UnregisterHookFunc

RegisterNetworkErrorListener adds a listener for when errors occur sending data over the wire

func (*GraphSync) RegisterOutgoingBlockHook

func (gs *GraphSync) RegisterOutgoingBlockHook(hook graphsync.OnOutgoingBlockHook) graphsync.UnregisterHookFunc

RegisterOutgoingBlockHook registers a hook that runs after each block is sent in a response

func (*GraphSync) RegisterOutgoingRequestHook

func (gs *GraphSync) RegisterOutgoingRequestHook(hook graphsync.OnOutgoingRequestHook) graphsync.UnregisterHookFunc

RegisterOutgoingRequestHook adds a hook that runs immediately prior to sending a new request

func (*GraphSync) RegisterOutgoingRequestProcessingListener

func (gs *GraphSync) RegisterOutgoingRequestProcessingListener(listener graphsync.OnRequestProcessingListener) graphsync.UnregisterHookFunc

RegisterOutgoingRequestProcessingListener adds a listener that gets called when a request actually begins processing (reaches the top of the outgoing request queue)

func (*GraphSync) RegisterPersistenceOption

func (gs *GraphSync) RegisterPersistenceOption(name string, lsys ipld.LinkSystem) error

RegisterPersistenceOption registers an alternate loader/storer combo that can be substituted for the default

func (*GraphSync) RegisterReceiverNetworkErrorListener

func (gs *GraphSync) RegisterReceiverNetworkErrorListener(listener graphsync.OnReceiverNetworkErrorListener) graphsync.UnregisterHookFunc

RegisterReceiverNetworkErrorListener adds a listener for when errors occur receiving data over the wire

func (*GraphSync) RegisterRequestUpdatedHook

func (gs *GraphSync) RegisterRequestUpdatedHook(hook graphsync.OnRequestUpdatedHook) graphsync.UnregisterHookFunc

RegisterRequestUpdatedHook registers a hook that runs when an update to a request is received

func (*GraphSync) RegisterRequestorCancelledListener

func (gs *GraphSync) RegisterRequestorCancelledListener(listener graphsync.OnRequestorCancelledListener) graphsync.UnregisterHookFunc

RegisterRequestorCancelledListener adds a listener on the responder for responses cancelled by the requestor

func (*GraphSync) Request

func (gs *GraphSync) Request(ctx context.Context, p peer.ID, root ipld.Link, selector ipld.Node, extensions ...graphsync.ExtensionData) (<-chan graphsync.ResponseProgress, <-chan error)

Request initiates a new GraphSync request to the given peer using the given selector spec.

func (*GraphSync) SendUpdate

func (gs *GraphSync) SendUpdate(ctx context.Context, requestID graphsync.RequestID, extensions ...graphsync.ExtensionData) error

SendUpdate sends an update for an in progress request or response

func (*GraphSync) Stats

func (gs *GraphSync) Stats() graphsync.Stats

Stats produces insight on the current state of a graphsync exchange

func (*GraphSync) Unpause

func (gs *GraphSync) Unpause(ctx context.Context, requestID graphsync.RequestID, extensions ...graphsync.ExtensionData) error

Unpause unpauses a request or response that was paused Can also send extensions with unpause

func (*GraphSync) UnregisterPersistenceOption

func (gs *GraphSync) UnregisterPersistenceOption(name string) error

UnregisterPersistenceOption unregisters an alternate loader/storer combo

type Option

type Option func(*graphsyncConfigOptions)

Option defines the functional option type that can be used to configure graphsync instances

func MaxInProgressIncomingRequests

func MaxInProgressIncomingRequests(maxInProgressIncomingRequests uint64) Option

MaxInProgressIncomingRequests changes the maximum number of incoming graphsync requests that are processed in parallel (default 6)

func MaxInProgressIncomingRequestsPerPeer

func MaxInProgressIncomingRequestsPerPeer(maxInProgressIncomingRequestsPerPeer uint64) Option

MaxInProgressIncomingRequestsPerPeer changes the maximum number of incoming graphsync requests that are processed in parallel on a per-peer basis. The value is not set by default. Useful in an environment for very high bandwidth graphsync responders serving many peers Note: if for some reason this is set higher than MaxInProgressIncomingRequests it will simply have no effect. Note: setting a value of zero will have no effect

func MaxInProgressOutgoingRequests

func MaxInProgressOutgoingRequests(maxInProgressOutgoingRequests uint64) Option

MaxInProgressOutgoingRequests changes the maximum number of outgoing graphsync requests that are processed in parallel (default 6)

func MaxLinksPerIncomingRequests

func MaxLinksPerIncomingRequests(maxLinksPerIncomingRequest uint64) Option

MaxLinksPerIncomingRequests changes the allowed number of links an incoming request can traverse before failing A value of 0 = infinity, or no limit

func MaxLinksPerOutgoingRequests

func MaxLinksPerOutgoingRequests(maxLinksPerOutgoingRequest uint64) Option

MaxLinksPerOutgoingRequests changes the allowed number of links an outgoing request can traverse before failing A value of 0 = infinity, or no limit

func MaxMemoryPerPeerResponder

func MaxMemoryPerPeerResponder(maxMemoryPerPeer uint64) Option

MaxMemoryPerPeerResponder defines the maximum amount of memory a peer may consume queueing up messages for a response

func MaxMemoryResponder

func MaxMemoryResponder(totalMaxMemory uint64) Option

MaxMemoryResponder defines the maximum amount of memory the responder may consume queueing up messages for a response in total

func MessageSendRetries

func MessageSendRetries(messageSendRetries int) Option

MessageSendRetries sets the number of times graphsync will send attempt to send a message before giving up. Lower to increase the speed at which an unresponsive peer is detected.

If not set, a default of 10 is used.

func PanicCallback

func PanicCallback(callbackFn panics.CallBackFn) Option

PanicCallback allows calling code to receive information about panics that Graphsync recovers from. Graphsync recovers panics that occur during per-request execution in order to keep the over all system running, although they are still treated as standard errors in normal execution flow.

func RejectAllRequestsByDefault

func RejectAllRequestsByDefault() Option

RejectAllRequestsByDefault means that without hooks registered that perform their own request validation, all requests are rejected

func SendMessageTimeout

func SendMessageTimeout(sendMessageTimeout time.Duration) Option

SendMessageTimeout sets the amount of time graphsync will wait for a message to go across the wire before giving up and trying again (up to max retries). Lower to increase the speed at which an unresponsive peer is detected.

If not set, a default of 10 minutes is used.

type PeerState

type PeerState struct {
	OutgoingState peerstate.PeerState
	IncomingState peerstate.PeerState
}

PeerState describes the state of graphsync for a given peer

Jump to

Keyboard shortcuts

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