block

package
v0.0.0-...-3511098 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockSize int = 4096
	AlignSize     = 4096
	HeadSize      = 8
	FootSize      = 8
	BodySize      = BlockSize - HeadSize - FootSize
)

Variables

This section is empty.

Functions

func Alloc

func Alloc(size int) []byte

func GetSize

func GetSize(payloadLen int) (int, int)

func Serialize

func Serialize(payload []byte, t Type, f Flags) ([]byte, error)

func SerializeTails

func SerializeTails(t []Tail, flags Flags) ([]byte, error)

Types

type Block

type Block struct {
	Version   uint8
	Type      Type
	Flags     Flags
	Length    uint16
	Reserved1 uint8
	Reserved2 uint8
	// Total 64 bits
	Body []byte
	Hash uint64
}

func Deserialize

func Deserialize(buff []byte) ([]Block, error)

type Flags

type Flags uint16

Flags

const (
	F_COMPRESSED Flags = 1 << 10
)

type SerializedTail

type SerializedTail [3][]byte

type Tail

type Tail struct {
	Pointer []byte
	Length  uint16
	Hash    []byte
}

func DeserializeTails

func DeserializeTails(rawpayload []byte) ([]Tail, error)

type Type

type Type uint8

Types

const (
	BodyType   Type = 1
	TailType   Type = 2
	AppendType Type = 3
	SkipType   Type = 17
)

Jump to

Keyboard shortcuts

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