metadata

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package metadata captures the metadata types known by the index-provider.

The metadata is used to provide information about how to retrieve data blocks associated to multihashes advertised by a provider. It is represented as an array of bytes in the indexer protocol, starting with a varint ProtocolID that defines how to decode the remaining bytes.

Two metadata types are currently represented here: Bitswap and GraphsyncFilecoinV1.

Index

Constants

View Source
const MaxMetadataSize = 1024

Variables

View Source
var (
	ErrTooLong = errors.New("too long")
)

Functions

This section is empty.

Types

type Bitswap added in v0.5.1

type Bitswap struct {
}

Bitswap represents the indexing metadata that uses multicodec.TransportBitswap.

func (Bitswap) ID added in v0.5.1

func (b Bitswap) ID() multicodec.Code

func (Bitswap) MarshalBinary added in v0.5.1

func (b Bitswap) MarshalBinary() ([]byte, error)

func (Bitswap) ReadFrom added in v0.5.1

func (b Bitswap) ReadFrom(r io.Reader) (n int64, err error)

func (Bitswap) UnmarshalBinary added in v0.5.1

func (b Bitswap) UnmarshalBinary(data []byte) error

type ErrInvalidMetadata added in v0.5.1

type ErrInvalidMetadata struct {
	Message string
}

func (ErrInvalidMetadata) Error added in v0.5.1

func (e ErrInvalidMetadata) Error() string

type GraphsyncFilecoinV1 added in v0.5.1

type GraphsyncFilecoinV1 struct {
	// PieceCID identifies the piece this data can be found in
	PieceCID cid.Cid
	// VerifiedDeal indicates if the deal is verified
	VerifiedDeal bool
	// FastRetrieval indicates whether the provider claims there is an unsealed copy
	FastRetrieval bool
}

GraphsyncFilecoinV1 represents the indexing metadata for multicodec.TransportGraphsyncFilecoinv1.

func (*GraphsyncFilecoinV1) ID added in v0.5.1

func (dtm *GraphsyncFilecoinV1) ID() multicodec.Code

func (*GraphsyncFilecoinV1) MarshalBinary added in v0.5.1

func (dtm *GraphsyncFilecoinV1) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*GraphsyncFilecoinV1) ReadFrom added in v0.5.1

func (dtm *GraphsyncFilecoinV1) ReadFrom(r io.Reader) (n int64, err error)

func (*GraphsyncFilecoinV1) UnmarshalBinary added in v0.5.1

func (dtm *GraphsyncFilecoinV1) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type Metadata added in v0.5.1

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

Metadata is data that provides information about how to retrieve the advertised content. Note that the content may be avaiable for retrieval over multiple protocols.

func (Metadata) Equal added in v0.5.1

func (m Metadata) Equal(other Metadata) bool

Equal checks whether this Metadata is equal with the other Metadata. The two are considered equal if they have the same transports with the same order.

func (*Metadata) Get added in v0.8.0

func (m *Metadata) Get(protocol multicodec.Code) Protocol

Get determines if a given protocol is included in metadata, and if so returned the parsed protocol.

func (*Metadata) Len added in v0.5.1

func (m *Metadata) Len() int

func (*Metadata) Less added in v0.5.1

func (m *Metadata) Less(one, other int) bool

func (*Metadata) MarshalBinary added in v0.5.1

func (m *Metadata) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*Metadata) Protocols added in v0.8.0

func (m *Metadata) Protocols() []multicodec.Code

Protocols returns the transport protocols advertised in this metadata

func (*Metadata) Swap added in v0.5.1

func (m *Metadata) Swap(one, other int)

func (*Metadata) UnmarshalBinary added in v0.5.1

func (m *Metadata) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Metadata) Validate added in v0.5.1

func (m *Metadata) Validate() error

Validate checks whether this Metadata is valid.

type MetadataContext added in v0.9.0

type MetadataContext interface {
	WithProtocol(id multicodec.Code, factory func() Protocol) MetadataContext
	New(t ...Protocol) Metadata
}

MetadataContext holds context for metadata serialization and deserialization.

var Default MetadataContext

type Protocol added in v0.5.1

type Protocol interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	io.ReaderFrom // Implement io.ReaderFrom so that transport can be incrementally decoded.

	// ID is the multicodec of the transport protocol represented by this Protocol.
	ID() multicodec.Code
}

Protocol represents the retrieval transport protocol of an advertisement.

func HTTPV1 added in v0.9.1

func HTTPV1() Protocol

type Unknown added in v0.9.0

type Unknown struct {
	Code    multicodec.Code
	Payload []byte
}

Unknown represents an unparsed metadata payload

func (*Unknown) ID added in v0.9.0

func (u *Unknown) ID() multicodec.Code

func (*Unknown) MarshalBinary added in v0.9.0

func (u *Unknown) MarshalBinary() ([]byte, error)

func (*Unknown) ReadFrom added in v0.9.0

func (u *Unknown) ReadFrom(r io.Reader) (n int64, err error)

func (*Unknown) UnmarshalBinary added in v0.9.0

func (u *Unknown) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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