message

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminalFailureCode

func IsTerminalFailureCode(status graphsync.ResponseStatusCode) bool

IsTerminalFailureCode returns true if the response code indicates the request terminated in failure.

func IsTerminalResponseCode

func IsTerminalResponseCode(status graphsync.ResponseStatusCode) bool

IsTerminalResponseCode returns true if the response code signals the end of the request

func IsTerminalSuccessCode

func IsTerminalSuccessCode(status graphsync.ResponseStatusCode) bool

IsTerminalSuccessCode returns true if the response code indicates the request terminated successfully.

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(topic Topic) *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 ld.Link, blockPresent bool)

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) Topic

func (b *Builder) Topic() Topic

Topic returns the identifier for notifications sent about this builder

type Exportable

type Exportable interface {
	ToProto() (*pb.Message, error)
	ToNet(w io.Writer) error
}

Exportable is an interface that can serialize to a protobuf

type GraphSyncMessage

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

func FromMsgReader

func FromMsgReader(r msgio.Reader) (GraphSyncMessage, error)

FromMsgReader can deserialize a protobuf message into a GraphySyncMessage.

func FromNet

func FromNet(r io.Reader) (GraphSyncMessage, error)

FromNet can read a network stream to deserialized a GraphSyncMessage

func (GraphSyncMessage) Blocks

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

func (GraphSyncMessage) Clone

func (gsm GraphSyncMessage) Clone() GraphSyncMessage

func (GraphSyncMessage) Empty

func (gsm GraphSyncMessage) Empty() bool

func (GraphSyncMessage) Loggable

func (gsm GraphSyncMessage) Loggable() map[string]interface{}

func (GraphSyncMessage) Requests

func (gsm GraphSyncMessage) Requests() []GraphSyncRequest

func (GraphSyncMessage) Responses

func (gsm GraphSyncMessage) Responses() []GraphSyncResponse

func (GraphSyncMessage) ToNet

func (gsm GraphSyncMessage) ToNet(w io.Writer) error

func (GraphSyncMessage) ToProto

func (gsm GraphSyncMessage) ToProto() (*pb.Message, error)

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 CancelRequest

func CancelRequest(id graphsync.RequestID) GraphSyncRequest

CancelRequest request generates a request to cancel an in progress request

func NewRequest

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

NewRequest builds a new Graphsync request

func UpdateRequest

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

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

func (GraphSyncRequest) Extension

func (gsr GraphSyncRequest) Extension(name graphsync.ExtensionName) ([]byte, bool)

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

func (GraphSyncRequest) ID

ID Returns the request ID for this Request

func (GraphSyncRequest) IsCancel

func (gsr GraphSyncRequest) IsCancel() bool

IsCancel returns true if this particular request is being cancelled

func (GraphSyncRequest) IsUpdate

func (gsr GraphSyncRequest) IsUpdate() bool

IsUpdate returns true if this particular request is being updated

func (GraphSyncRequest) MergeExtensions

func (gsr GraphSyncRequest) MergeExtensions(extensions []graphsync.ExtensionData, mergeFunc func(name graphsync.ExtensionName, oldData []byte, newData []byte) ([]byte, 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() ld.Node

Selector returns the byte representation of the selector for this request

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

func NewResponse(requestID graphsync.RequestID,
	status graphsync.ResponseStatusCode,
	extensions ...graphsync.ExtensionData) GraphSyncResponse

NewResponse builds a new Graphsync response

func (GraphSyncResponse) Extension

func (gsr GraphSyncResponse) Extension(name graphsync.ExtensionName) ([]byte, bool)

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

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

type Topic

type Topic uint64

Topic is an identifier for notifications about this response builder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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