Documentation ¶
Index ¶
- type Archive
- type ArchiveHeader
- type ArchiveHeaderWireFormat
- type BlockWireFormat
- func (b *BlockWireFormat[T, R]) Id() T
- func (b *BlockWireFormat[T, R]) MarshalBinary() ([]byte, error)
- func (b *BlockWireFormat[T, R]) RawData() []byte
- func (b *BlockWireFormat[T, R]) Read(reader core.ByteAndBlockReader) error
- func (b *BlockWireFormat[T, R]) Size() int64
- func (b *BlockWireFormat[T, R]) UnmarshalBinary(data []byte) error
- func (b *BlockWireFormat[T, R]) Write(writer io.Writer) error
- type BlocksMessage
- type StatusMessage
- func (msg *StatusMessage[I, R]) MarshalBinary() ([]byte, error)
- func (msg *StatusMessage[I, R]) MarshalCBOR() ([]byte, error)
- func (msg *StatusMessage[I, R]) Read(reader core.ByteAndBlockReader) error
- func (msg *StatusMessage[I, R]) UnmarshalBinary(data []byte) error
- func (msg *StatusMessage[I, R]) UnmarshalCBOR(data []byte) error
- func (msg *StatusMessage[I, R]) Write(writer io.Writer) error
- type StatusMessageWireFormat
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 ¶
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 ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
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.
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]) 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.
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.
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.
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.