dag

package
v0.0.0-...-ad76458 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 19 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChunkSize = 2048 * 1024 // 2048 * 1024 bytes = 2 megabytes

Functions

func GenerateDummyDirectory

func GenerateDummyDirectory(path string, maxItems int, maxDepth int)

func GetHash

func GetHash(hash string) string

func GetLabel

func GetLabel(hash string) string

func HasLabel

func HasLabel(hash string) bool

func SetChunkSize

func SetChunkSize(size int)

Types

type ClassicTreeBranch

type ClassicTreeBranch struct {
	Leaf  string
	Proof *merkletree.Proof
}

type Dag

type Dag struct {
	Root  string
	Leafs map[string]*DagLeaf
}

func CreateDag

func CreateDag(path string, timestampRoot bool) (*Dag, error)

func CreateDagAdvanced

func CreateDagAdvanced(path string, additionalData map[string]string) (*Dag, error)

func ReadDag

func ReadDag(path string) (*Dag, error)

func (*Dag) CreateDirectory

func (dag *Dag) CreateDirectory(path string) error

func (*Dag) GetContentFromLeaf

func (dag *Dag) GetContentFromLeaf(leaf *DagLeaf) ([]byte, error)

func (*Dag) IterateDag

func (d *Dag) IterateDag(processLeaf func(leaf *DagLeaf, parent *DagLeaf) error) error

func (*Dag) ToCBOR

func (dag *Dag) ToCBOR() ([]byte, error)

func (*Dag) ToJSON

func (dag *Dag) ToJSON() ([]byte, error)

func (*Dag) Verify

func (dag *Dag) Verify() error

type DagBuilder

type DagBuilder struct {
	Leafs map[string]*DagLeaf
}

func CreateDagBuilder

func CreateDagBuilder() *DagBuilder

func (*DagBuilder) AddLeaf

func (b *DagBuilder) AddLeaf(leaf *DagLeaf, parentLeaf *DagLeaf) error

func (*DagBuilder) BuildDag

func (b *DagBuilder) BuildDag(root string) *Dag

func (*DagBuilder) GetLatestLabel

func (b *DagBuilder) GetLatestLabel() string

func (*DagBuilder) GetNextAvailableLabel

func (b *DagBuilder) GetNextAvailableLabel() string

type DagLeaf

type DagLeaf struct {
	Hash              string
	ItemName          string
	Type              LeafType
	ContentHash       []byte
	Content           []byte
	ClassicMerkleRoot []byte
	CurrentLinkCount  int
	LatestLabel       string
	LeafCount         int
	Links             map[string]string
	ParentHash        string
	AdditionalData    map[string]string
}

func CreateDummyLeaf

func CreateDummyLeaf(name string) (*DagLeaf, error)

func FindRandomChild

func FindRandomChild(leaf *DagLeaf, leafs map[string]*DagLeaf) *DagLeaf
func (leaf *DagLeaf) AddLink(hash string)

func (*DagLeaf) Clone

func (leaf *DagLeaf) Clone() *DagLeaf

func (*DagLeaf) CreateDirectoryLeaf

func (leaf *DagLeaf) CreateDirectoryLeaf(path string, dag *Dag) error

func (*DagLeaf) GetBranch

func (leaf *DagLeaf) GetBranch(key string) (*ClassicTreeBranch, error)
func (leaf *DagLeaf) HasLink(hash string) bool

func (*DagLeaf) SetLabel

func (leaf *DagLeaf) SetLabel(label string)

func (*DagLeaf) VerifyBranch

func (leaf *DagLeaf) VerifyBranch(branch *ClassicTreeBranch) error

func (*DagLeaf) VerifyLeaf

func (leaf *DagLeaf) VerifyLeaf() error

func (*DagLeaf) VerifyRootLeaf

func (leaf *DagLeaf) VerifyRootLeaf() error

type DagLeafBuilder

type DagLeafBuilder struct {
	ItemName string
	Label    int64
	LeafType LeafType
	Data     []byte
	Links    map[string]string
}

func CreateDagLeafBuilder

func CreateDagLeafBuilder(name string) *DagLeafBuilder
func (b *DagLeafBuilder) AddLink(label string, hash string)

func (*DagLeafBuilder) BuildLeaf

func (b *DagLeafBuilder) BuildLeaf(additionalData map[string]string) (*DagLeaf, error)

func (*DagLeafBuilder) BuildRootLeaf

func (b *DagLeafBuilder) BuildRootLeaf(dag *DagBuilder, additionalData map[string]string) (*DagLeaf, error)

func (*DagLeafBuilder) SetData

func (b *DagLeafBuilder) SetData(data []byte)

func (*DagLeafBuilder) SetType

func (b *DagLeafBuilder) SetType(leafType LeafType)

type LeafType

type LeafType string
const (
	FileLeafType      LeafType = "file"
	ChunkLeafType     LeafType = "chunk"
	DirectoryLeafType LeafType = "directory"
)

type MetaData

type MetaData struct {
	Deleted []string
}

Jump to

Keyboard shortcuts

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