chunker

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recombine

func Recombine(chunks []EncodedChunk, w io.Writer) error

Recombine recombines all of the chunks. It starts with the last chunk (which is the first one to be created) and works it's way to the first one

Types

type Chunker

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

Chunker struct

func NewChunker

func NewChunker(reader io.Reader, totalSize int64) (*Chunker, error)

NewChunker creates a new chunker struct

func (*Chunker) ChunkAll

func (c *Chunker) ChunkAll() ([]EncodedChunk, error)

ChunkAll is a commodity function designed to returns all the chunks from an io.Reader

func (*Chunker) EncodedSize

func (c *Chunker) EncodedSize() int64

EncodedSize calculates the Base64RawURL encoded size of our chunk

func (*Chunker) Next

func (c *Chunker) Next() (*EncodedChunk, error)

Next retrieves the next chunk from the io.Reader

func (*Chunker) SetChunkSize

func (c *Chunker) SetChunkSize(size int64)

SetChunkSize sets the chunk size

func (*Chunker) Size

func (c *Chunker) Size() int64

Size retrieves the total size of the chunk

func (*Chunker) TotalChunks

func (c *Chunker) TotalChunks() int64

TotalChunks returns the total chunks

type EncodedChunk

type EncodedChunk struct {
	Data     string `json:"data"`
	Position int64  `json:"position"`
}

EncodedChunk is the data structure representing an encoded chunk on the arweave

func (*EncodedChunk) MarshalJSON

func (ec *EncodedChunk) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON

func (*EncodedChunk) UnmarshalJSON

func (ec *EncodedChunk) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals as JSON

type EncodedChunkJSON

type EncodedChunkJSON struct {
	Data     string `json:"data"`
	Position int64  `json:"position"`
}

EncodedChunkJSON is the intermediary data to encode/decode into JSON

func NewEncodedChunkJSON

func NewEncodedChunkJSON(ec *EncodedChunk) *EncodedChunkJSON

NewEncodedChunkJSON creates a new EncodedChunkJSON struct

Jump to

Keyboard shortcuts

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