message

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0, MIT Imports: 7 Imported by: 15

Documentation

Index

Constants

View Source
const (

	// RequestAcknowledged means the request was received and is being worked on.
	RequestAcknowledged = GraphSyncResponseStatusCode(10)
	// AdditionalPeers means additional peers were found that may be able
	// to satisfy the request and contained in the extra block of the response.
	AdditionalPeers = GraphSyncResponseStatusCode(11)
	// NotEnoughGas means fulfilling this request requires payment.
	NotEnoughGas = GraphSyncResponseStatusCode(12)
	// OtherProtocol means a different type of response than GraphSync is
	// contained in extra.
	OtherProtocol = GraphSyncResponseStatusCode(13)
	// PartialResponse may include blocks and metadata about the in progress response
	// in extra.
	PartialResponse = GraphSyncResponseStatusCode(14)

	// RequestCompletedFull means the entire fulfillment of the GraphSync request
	// was sent back.
	RequestCompletedFull = GraphSyncResponseStatusCode(20)
	// RequestCompletedPartial means the response is completed, and part of the
	// GraphSync request was sent back, but not the complete request.
	RequestCompletedPartial = GraphSyncResponseStatusCode(21)

	// RequestRejected means the node did not accept the incoming request.
	RequestRejected = GraphSyncResponseStatusCode(30)
	// RequestFailedBusy means the node is too busy, try again later. Backoff may
	// be contained in extra.
	RequestFailedBusy = GraphSyncResponseStatusCode(31)
	// RequestFailedUnknown means the request failed for an unspecified reason. May
	// contain data about why in extra.
	RequestFailedUnknown = GraphSyncResponseStatusCode(32)
	// RequestFailedLegal means the request failed for legal reasons.
	RequestFailedLegal = GraphSyncResponseStatusCode(33)
	// RequestFailedContentNotFound means the respondent does not have the content.
	RequestFailedContentNotFound = GraphSyncResponseStatusCode(34)
)

Variables

This section is empty.

Functions

func IsTerminalFailureCode

func IsTerminalFailureCode(status GraphSyncResponseStatusCode) bool

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

func IsTerminalResponseCode

func IsTerminalResponseCode(status GraphSyncResponseStatusCode) bool

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

func IsTerminalSuccessCode

func IsTerminalSuccessCode(status GraphSyncResponseStatusCode) bool

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

Types

type Exportable

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

Exportable is an interface that can serialize to a protobuf

type GraphSyncMessage

type GraphSyncMessage interface {
	Requests() []GraphSyncRequest

	Responses() []GraphSyncResponse

	Blocks() []blocks.Block

	AddRequest(graphSyncRequest GraphSyncRequest)

	AddResponse(graphSyncResponse GraphSyncResponse)

	AddBlock(blocks.Block)

	Empty() bool

	Exportable

	Loggable() map[string]interface{}
}

GraphSyncMessage is interface that can be serialized and deserialized to send over the GraphSync network

func FromNet

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

FromNet can read a network stream to deserialized a GraphSyncMessage

func FromPBReader

func FromPBReader(pbr ggio.Reader) (GraphSyncMessage, error)

FromPBReader can deserialize a protobuf message into a GraphySyncMessage.

func New

func New() GraphSyncMessage

New initializes a new blank GraphSyncMessage

type GraphSyncPriority

type GraphSyncPriority int32

GraphSyncPriority a priority for a GraphSync request.

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 GraphSyncRequestID) GraphSyncRequest

CancelRequest request generates a request to cancel an in progress request

func NewRequest

func NewRequest(id GraphSyncRequestID,
	root cid.Cid,
	selector []byte,
	priority GraphSyncPriority) GraphSyncRequest

NewRequest builds a new Graphsync request

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

func (gsr GraphSyncRequest) Priority() GraphSyncPriority

Priority returns the priority of this request

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() []byte

Selector returns the byte representation of the selector for this request

type GraphSyncRequestID

type GraphSyncRequestID int32

GraphSyncRequestID is a unique identifier for a GraphSync 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 GraphSyncRequestID,
	status GraphSyncResponseStatusCode,
	extra []byte) GraphSyncResponse

NewResponse builds a new Graphsync response

func (GraphSyncResponse) Extra

func (gsr GraphSyncResponse) Extra() []byte

Extra returns any metadata on a response

func (GraphSyncResponse) RequestID

func (gsr GraphSyncResponse) RequestID() GraphSyncRequestID

RequestID returns the request ID for this response

func (GraphSyncResponse) Status

Status returns the status for a response

type GraphSyncResponseStatusCode

type GraphSyncResponseStatusCode int32

GraphSyncResponseStatusCode is a status returned for a GraphSync Request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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