core

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// DefaultChunkSize represents the default chunk size in bytes.
	DefaultChunkSize = 256

	// DefaultSegmentMaxChunks represents the default maximum number of chunks within a segment.
	DefaultSegmentMaxChunks = 1024

	// DefaultSegmentSize represents the default segment size in bytes.
	DefaultSegmentSize = DefaultChunkSize * DefaultSegmentMaxChunks
)

Variables

View Source
var (
	EmptyChunk     = make([]byte, DefaultChunkSize)
	EmptyChunkHash = crypto.Keccak256Hash(EmptyChunk)
)
View Source
var (
	// ErrFileRequired is returned when manipulate on a folder.
	ErrFileRequired = errors.New("file required")

	// ErrFileEmpty is returned when empty file opened.
	ErrFileEmpty = errors.New("file is empty")
)

Functions

func ComputePaddedSize

func ComputePaddedSize(chunks uint64) (uint64, uint64)

func Exists

func Exists(name string) (bool, error)

func IteratorPaddedSize

func IteratorPaddedSize(dataSize int64, flowPadding bool) uint64

func MerkleTree

func MerkleTree(data IterableData) (*merkle.Tree, error)

func NumSegmentsPadded

func NumSegmentsPadded(data IterableData) int

func NumSplits

func NumSplits(total int64, unit int) uint64

func ReadAt

func ReadAt(data IterableData, readSize int, offset int64, paddedSize uint64) ([]byte, error)

func SegmentRoot

func SegmentRoot(chunks []byte, emptyChunksPadded ...uint64) common.Hash

Types

type DataInMemory

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

func NewDataInMemory

func NewDataInMemory(data []byte) (*DataInMemory, error)

func (*DataInMemory) Iterate

func (data *DataInMemory) Iterate(offset int64, batch int64, flowPadding bool) Iterator

func (*DataInMemory) NumChunks

func (data *DataInMemory) NumChunks() uint64

func (*DataInMemory) NumSegments

func (data *DataInMemory) NumSegments() uint64

func (*DataInMemory) PaddedSize

func (data *DataInMemory) PaddedSize() uint64

func (*DataInMemory) Read

func (data *DataInMemory) Read(buf []byte, offset int64) (int, error)

func (*DataInMemory) Size

func (data *DataInMemory) Size() int64

type File

type File struct {
	os.FileInfo
	// contains filtered or unexported fields
}

func Open

func Open(name string) (*File, error)

func (*File) Close

func (file *File) Close() error

func (*File) Iterate

func (file *File) Iterate(offset int64, batch int64, flowPadding bool) Iterator

func (*File) NumChunks

func (file *File) NumChunks() uint64

func (*File) NumSegments

func (file *File) NumSegments() uint64

func (*File) PaddedSize

func (file *File) PaddedSize() uint64

func (*File) Read

func (file *File) Read(buf []byte, offset int64) (int, error)

type FileIterator

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

func (*FileIterator) Current

func (it *FileIterator) Current() []byte

func (*FileIterator) Next

func (it *FileIterator) Next() (bool, error)

type Flow

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

func NewFlow

func NewFlow(data IterableData, tags []byte) *Flow

func (*Flow) CreateSubmission

func (flow *Flow) CreateSubmission() (*contract.Submission, error)

type IterableData

type IterableData interface {
	NumChunks() uint64
	NumSegments() uint64
	Size() int64
	PaddedSize() uint64
	Iterate(offset int64, batch int64, flowPadding bool) Iterator
	Read(buf []byte, offset int64) (int, error)
}

type Iterator

type Iterator interface {
	Next() (bool, error)
	Current() []byte
}

type MemoryDataIterator

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

func (*MemoryDataIterator) Current

func (it *MemoryDataIterator) Current() []byte

func (*MemoryDataIterator) Next

func (it *MemoryDataIterator) Next() (bool, error)

type TreeBuilderInitializer

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

func (*TreeBuilderInitializer) ParallelCollect

func (t *TreeBuilderInitializer) ParallelCollect(result *parallel.Result) error

ParallelCollect implements parallel.Interface.

func (*TreeBuilderInitializer) ParallelDo

func (t *TreeBuilderInitializer) ParallelDo(routine int, task int) (interface{}, error)

ParallelDo implements parallel.Interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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