metadata

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0, MIT Imports: 14 Imported by: 35

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

type Bitswap struct {
}

Bitswap represents the indexing metadata that uses multicodec.TransportBitswap.

func (Bitswap) ID

func (b Bitswap) ID() multicodec.Code

func (Bitswap) MarshalBinary

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

func (Bitswap) ReadFrom

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

func (Bitswap) UnmarshalBinary

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

type ErrInvalidMetadata

type ErrInvalidMetadata struct {
	Message string
}

func (ErrInvalidMetadata) Error

func (e ErrInvalidMetadata) Error() string

type GraphsyncFilecoinV1

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

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

func (*GraphsyncFilecoinV1) MarshalBinary

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

MarshalBinary implements encoding.BinaryMarshaler.

func (*GraphsyncFilecoinV1) ReadFrom

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

func (*GraphsyncFilecoinV1) UnmarshalBinary

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

UnmarshalBinary implements encoding.BinaryUnmarshaler.

type IpfsGatewayHttp added in v0.0.8

type IpfsGatewayHttp struct {
}

IpfsGatewayHttp represents the indexing metadata that uses multicodec.TransportIpfsGatewayHttp.

func (IpfsGatewayHttp) ID added in v0.0.8

func (b IpfsGatewayHttp) ID() multicodec.Code

func (IpfsGatewayHttp) MarshalBinary added in v0.0.8

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

func (IpfsGatewayHttp) ReadFrom added in v0.0.8

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

func (IpfsGatewayHttp) UnmarshalBinary added in v0.0.8

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

type Metadata

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

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

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

func (m *Metadata) Len() int

func (*Metadata) Less

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

func (*Metadata) MarshalBinary

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

MarshalBinary implements encoding.BinaryMarshaler.

func (*Metadata) Protocols

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

Protocols returns the transport protocols advertised in this metadata

func (*Metadata) Swap

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

func (*Metadata) UnmarshalBinary

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

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Metadata) Validate

func (m *Metadata) Validate() error

Validate checks whether this Metadata is valid.

type MetadataContext

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

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

func HTTPV1() Protocol

type Unknown

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

Unknown represents an unparsed metadata payload

func (*Unknown) ID

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

func (*Unknown) MarshalBinary

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

func (*Unknown) ReadFrom

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

func (*Unknown) UnmarshalBinary

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