message

package
v0.13.12 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder captures components of a message across multiple requests for a given peer and then generates the corresponding GraphSync message when ready to send

func NewBuilder

func NewBuilder() *Builder

NewBuilder generates a new Builder.

func (*Builder) AddBlock

func (b *Builder) AddBlock(block blocks.Block)

AddBlock adds the given block to the message.

func (*Builder) AddExtensionData

func (b *Builder) AddExtensionData(requestID graphsync.RequestID, extension graphsync.ExtensionData)

AddExtensionData adds the given extension data to to the message

func (b *Builder) AddLink(requestID graphsync.RequestID, link ipld.Link, linkAction graphsync.LinkAction)

AddLink adds the given link and whether its block is present to the message for the given request ID.

func (*Builder) AddRequest

func (b *Builder) AddRequest(request GraphSyncRequest)

AddRequest registers a new request to be added to the message.

func (*Builder) AddResponseCode

func (b *Builder) AddResponseCode(requestID graphsync.RequestID, status graphsync.ResponseStatusCode)

AddResponseCode marks the given request as completed in the message, as well as whether the graphsync request responded with complete or partial data.

func (*Builder) BlockSize

func (b *Builder) BlockSize() uint64

BlockSize returns the total size of all blocks in this message

func (*Builder) Build

func (b *Builder) Build() (GraphSyncMessage, error)

Build assembles and encodes message data from the added requests, links, and blocks.

func (*Builder) Empty

func (b *Builder) Empty() bool

Empty returns true if there is no content to send

func (*Builder) ScrubResponses

func (b *Builder) ScrubResponses(requestIDs []graphsync.RequestID) uint64

ScrubResponse removes a response from a message and any blocks only referenced by that response

type GraphSyncLinkMetadata

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

GraphSyncLinkMetadata is a graphsync.LinkMetadata compatible type that is used for holding and accessing the metadata for a request

func NewLinkMetadata

func NewLinkMetadata(md []GraphSyncLinkMetadatum) GraphSyncLinkMetadata

NewLinkMetadata generates a new graphsync.LinkMetadata compatible object, used for accessing the metadata in a message

func (GraphSyncLinkMetadata) Iterate

Iterate over the metadata one by one via a graphsync.LinkMetadataIterator callback function

func (GraphSyncLinkMetadata) Length

func (gslm GraphSyncLinkMetadata) Length() int64

Length returns the number of metadata entries

func (GraphSyncLinkMetadata) RawMetadata

func (gslm GraphSyncLinkMetadata) RawMetadata() []GraphSyncLinkMetadatum

RawMetadata accesses the raw GraphSyncLinkMetadatum contained in this object, this is not exposed via the graphsync.LinkMetadata API and in general the Iterate() method should be used instead for accessing the individual metadata

type GraphSyncLinkMetadatum

type GraphSyncLinkMetadatum struct {
	Link   cid.Cid
	Action graphsync.LinkAction
}

GraphSyncLinkMetadatum is used for holding individual pieces of metadata, this is not intended for public consumption and is used within GraphSyncLinkMetadata to contain the metadata

type GraphSyncMessage

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

GraphSyncMessage is the internal representation form of a message sent or received over the wire

func NewMessage

func NewMessage(
	requests map[graphsync.RequestID]GraphSyncRequest,
	responses map[graphsync.RequestID]GraphSyncResponse,
	blocks map[cid.Cid]blocks.Block,
) GraphSyncMessage

NewMessage generates a new message containing the provided requests, responses and blocks

func (GraphSyncMessage) Blocks

func (gsm GraphSyncMessage) Blocks() []blocks.Block

Blocks provides a copy of all of the blocks in this message

func (GraphSyncMessage) Clone

func (gsm GraphSyncMessage) Clone() GraphSyncMessage

Clone returns a shallow copy of this GraphSyncMessage

func (GraphSyncMessage) Empty

func (gsm GraphSyncMessage) Empty() bool

Empty returns true if this message contains no meaningful content: requests, responses, or blocks

func (GraphSyncMessage) Requests

func (gsm GraphSyncMessage) Requests() []GraphSyncRequest

Requests provides a copy of the requests in this message

func (GraphSyncMessage) ResponseCodes

ResponseCodes returns a list of ResponseStatusCodes contained in the responses in this GraphSyncMessage

func (GraphSyncMessage) Responses

func (gsm GraphSyncMessage) Responses() []GraphSyncResponse

Responses provides a copy of the responses in this message

func (GraphSyncMessage) String

func (gsm GraphSyncMessage) String() string

String returns a human-readable (multi-line) form of a GraphSyncMessage and its contents

type GraphSyncRequest

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

GraphSyncRequest is a struct to capture data on a request contained in a GraphSyncMessage.

func NewCancelRequest

func NewCancelRequest(id graphsync.RequestID) GraphSyncRequest

NewCancelRequest request generates a request to cancel an in progress request

func NewRequest

func NewRequest(id graphsync.RequestID,
	root cid.Cid,
	selector ipld.Node,
	priority graphsync.Priority,
	extensions ...graphsync.ExtensionData) GraphSyncRequest

NewRequest builds a new GraphSyncRequest

func NewUpdateRequest

func NewUpdateRequest(id graphsync.RequestID, extensions ...graphsync.ExtensionData) GraphSyncRequest

NewUpdateRequest generates a new request to update an in progress request with the given extensions

func (GraphSyncRequest) Extension

func (gsr GraphSyncRequest) Extension(name graphsync.ExtensionName) (datamodel.Node, bool)

Extension returns the content for an extension on a response, or errors if extension is not present

func (GraphSyncRequest) ExtensionNames

func (gsr GraphSyncRequest) ExtensionNames() []graphsync.ExtensionName

ExtensionNames returns the names of the extensions included in this request

func (GraphSyncRequest) ID

ID Returns the request ID for this Request

func (GraphSyncRequest) MergeExtensions

func (gsr GraphSyncRequest) MergeExtensions(extensions []graphsync.ExtensionData, mergeFunc func(name graphsync.ExtensionName, oldData datamodel.Node, newData datamodel.Node) (datamodel.Node, error)) (GraphSyncRequest, error)

MergeExtensions merges the given list of extensions to produce a new request with the combination of the old request plus the new extensions. When an old extension and a new extension are both present, mergeFunc is called to produce the result

func (GraphSyncRequest) Priority

func (gsr GraphSyncRequest) Priority() graphsync.Priority

Priority returns the priority of this request

func (GraphSyncRequest) ReplaceExtensions

func (gsr GraphSyncRequest) ReplaceExtensions(extensions []graphsync.ExtensionData) GraphSyncRequest

ReplaceExtensions merges the extensions given extensions into the request to create a new request, but always uses new data

func (GraphSyncRequest) Root

func (gsr GraphSyncRequest) Root() cid.Cid

Root returns the CID to the root block of this request

func (GraphSyncRequest) Selector

func (gsr GraphSyncRequest) Selector() ipld.Node

Selector returns the byte representation of the selector for this request

func (GraphSyncRequest) String

func (gsr GraphSyncRequest) String() string

String returns a human-readable form of a GraphSyncRequest

func (GraphSyncRequest) Type

RequestType returns the type of this request (new, cancel, update, etc.)

type GraphSyncResponse

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

GraphSyncResponse is an struct to capture data on a response sent back in a GraphSyncMessage.

func NewResponse

NewResponse builds a new Graphsync response

func (GraphSyncResponse) Extension

Extension returns the content for an extension on a response, or errors if extension is not present

func (GraphSyncResponse) ExtensionNames

func (gsr GraphSyncResponse) ExtensionNames() []graphsync.ExtensionName

ExtensionNames returns the names of the extensions included in this request

func (GraphSyncResponse) Metadata

func (gsr GraphSyncResponse) Metadata() graphsync.LinkMetadata

Metadata returns an instance of a graphsync.LinkMetadata for accessing the individual metadatum via an iterator

func (GraphSyncResponse) RequestID

func (gsr GraphSyncResponse) RequestID() graphsync.RequestID

RequestID returns the request ID for this response

func (GraphSyncResponse) Status

Status returns the status for a response

func (GraphSyncResponse) String

func (gsr GraphSyncResponse) String() string

String returns a human-readable form of a GraphSyncResponse

type MessageHandler

type MessageHandler interface {
	FromNet(peer.ID, io.Reader) (GraphSyncMessage, error)
	FromMsgReader(peer.ID, msgio.Reader) (GraphSyncMessage, error)
	ToNet(peer.ID, GraphSyncMessage, io.Writer) error
}

MessageHandler provides a consistent interface for maintaining per-peer state within the differnet protocol versions

type MessagePartWithExtensions

type MessagePartWithExtensions interface {
	ExtensionNames() []graphsync.ExtensionName
	Extension(name graphsync.ExtensionName) (datamodel.Node, bool)
}

MessagePartWithExtensions is an interface for accessing metadata on both requests and responses, which have a consistent extension accessor mechanism

Directories

Path Synopsis
v1

Jump to

Keyboard shortcuts

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