messages

package
v0.0.0-...-ee0e00b Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive[T core.BlockId, R core.BlockIdRef[T]] struct {
	Header ArchiveHeader[T]   `json:"hdr"`
	Blocks []core.RawBlock[T] `json:"blocks"`
}

Archive represents a content-addressable archive (CAR).

func (*Archive[T, R]) MarshalBinary

func (ah *Archive[T, R]) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Archive[T, R]) Read

func (car *Archive[T, R]) Read(reader core.ByteAndBlockReader) error

Read reads the archive from the reader.

func (*Archive[T, R]) UnmarshalBinary

func (car *Archive[T, R]) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*Archive[T, R]) Write

func (car *Archive[T, R]) Write(writer io.Writer) error

Write writes the archive to the writer.

type ArchiveHeader

type ArchiveHeader[T core.BlockId] ArchiveHeaderWireFormat[T] // Avoid recursion due to cbor marshalling falling back to using MarshalBinary

ArchiveHeader is the header of content-addressable archive (CAR).

func (*ArchiveHeader[T]) MarshalBinary

func (ah *ArchiveHeader[T]) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*ArchiveHeader[T]) Read

func (ah *ArchiveHeader[T]) Read(reader core.ByteAndBlockReader) error

Read reads the archive header from the reader.

func (*ArchiveHeader[T]) UnmarshalBinary

func (ah *ArchiveHeader[T]) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*ArchiveHeader[T]) Write

func (ah *ArchiveHeader[T]) Write(writer io.Writer) error

Write writes the archive header to the writer.

type ArchiveHeaderWireFormat

type ArchiveHeaderWireFormat[T core.BlockId] struct {
	Version int `json:"version"`
	Roots   []T `json:"roots"`
}

ArchiveHeaderWireFormat is the wire format for the archive header.

type BlockWireFormat

type BlockWireFormat[T core.BlockId, R core.BlockIdRef[T]] struct {
	IdRef R      `json:"id"`
	Data  []byte `json:"data"`
}

BlockWireFormat is the wire format for a block id or block id reference.

func CastBlockWireFormat

func CastBlockWireFormat[T core.BlockId, R core.BlockIdRef[T]](rawBlock core.RawBlock[T]) *BlockWireFormat[T, R]

CastBlockWireFormat casts a raw block to a block wire format.

func (*BlockWireFormat[T, R]) Id

func (b *BlockWireFormat[T, R]) Id() T

Id returns the block id.

func (*BlockWireFormat[T, R]) MarshalBinary

func (b *BlockWireFormat[T, R]) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*BlockWireFormat[T, R]) RawData

func (b *BlockWireFormat[T, R]) RawData() []byte

RawData returns the raw data of the encoded block.

func (*BlockWireFormat[T, R]) Read

func (b *BlockWireFormat[T, R]) Read(reader core.ByteAndBlockReader) error

Read reads from the reader into the block wire format.

func (*BlockWireFormat[T, R]) Size

func (b *BlockWireFormat[T, R]) Size() int64

Size returns the size of the block.

func (*BlockWireFormat[T, R]) UnmarshalBinary

func (b *BlockWireFormat[T, R]) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*BlockWireFormat[T, R]) Write

func (b *BlockWireFormat[T, R]) Write(writer io.Writer) error

BlockWireFormat is the wire format.

type BlocksMessage

type BlocksMessage[T core.BlockId, R core.BlockIdRef[T]] struct {
	Car Archive[T, R]
}

BlocksMessage state and the archive.

func NewBlocksMessage

func NewBlocksMessage[
	T core.BlockId,
	R core.BlockIdRef[T],
](blocks []core.RawBlock[T]) *BlocksMessage[T, R]

NewBlocksMessage creates a new blocks message.

func (*BlocksMessage[T, B]) MarshalBinary

func (msg *BlocksMessage[T, B]) MarshalBinary() ([]byte, error)

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*BlocksMessage[T, B]) Read

func (msg *BlocksMessage[T, B]) Read(reader core.ByteAndBlockReader) error

Read reads the blocks message from the reader.

func (*BlocksMessage[T, B]) UnmarshalBinary

func (msg *BlocksMessage[T, B]) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*BlocksMessage[T, B]) Write

func (msg *BlocksMessage[T, B]) Write(writer io.Writer) error

Write writes the blocks message to the writer.

type StatusMessage

type StatusMessage[I core.BlockId, R core.BlockIdRef[I]] StatusMessageWireFormat[I, R]

StatusMessage represents a status message.

func NewStatusMessage

func NewStatusMessage[I core.BlockId, R core.BlockIdRef[I]](have filter.Filter[I], want []I) *StatusMessage[I, R]

NewStatusMessage creates a new status message.

func (*StatusMessage[I, R]) MarshalBinary

func (msg *StatusMessage[I, R]) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*StatusMessage[I, R]) MarshalCBOR

func (msg *StatusMessage[I, R]) MarshalCBOR() ([]byte, error)

MarshalCBOR implements the cbor.Marshaler interface.

func (*StatusMessage[I, R]) Read

func (msg *StatusMessage[I, R]) Read(reader core.ByteAndBlockReader) error

Read reads the status message from the reader.

func (*StatusMessage[I, R]) UnmarshalBinary

func (msg *StatusMessage[I, R]) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*StatusMessage[I, R]) UnmarshalCBOR

func (msg *StatusMessage[I, R]) UnmarshalCBOR(data []byte) error

UnmarshalCBOR implements the cbor.Unmarshaler interface.

func (*StatusMessage[I, R]) Write

func (msg *StatusMessage[I, R]) Write(writer io.Writer) error

Write writes the status message to the writer.

type StatusMessageWireFormat

type StatusMessageWireFormat[I core.BlockId, R core.BlockIdRef[I]] struct {
	Have *filter.FilterWireFormat[I] `json:"have"`
	Want []I                         `json:"want"`
}

StatusMessageWireFormat is the wire format of a status message.

Jump to

Keyboard shortcuts

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