tree

package
v0.0.0-...-c3be179 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Branch

type Branch []Node

Branch is an implementation of node the first Node of the slide is the root tree, the last one the current folder/directory

func (Branch) Hash

func (b Branch) Hash() []byte

Hash of the last node of the branch

func (Branch) IsDir

func (b Branch) IsDir() bool

IsDir returns true if the last node of the branch is a directory node

func (Branch) Name

func (b Branch) Name() string

Name of the last node of the branch

func (Branch) Path

func (b Branch) Path() string

Path of the last node of the branch

func (Branch) PreHash

func (b Branch) PreHash() []byte

PreHash of the last node of the branch

func (Branch) Subnodes

func (b Branch) Subnodes() []Node

Subnodes of the last node of the branch

type Node

type Node interface {
	Name() string     // name of the folder or file
	PreHash() []byte  // hash of the content of the folder or file
	Hash() []byte     // combined hash of the name and prehash of the node
	IsDir() bool      // wether the node is a directory
	Subnodes() []Node // children nodes of a folder node
}

Node represents a Node of the merkletree a directory is a branch node while a file is a leaf node

type SerializableNode

type SerializableNode struct {
	Name     string             `json:"name"`
	PreHash  string             `json:"prehash"`
	Hash     string             `json:"hash"`
	IsDir    bool               `json:"isdir"`
	Subnodes []SerializableNode `json:"subnodes"`
}

SerializableNode is used to serialize/deserialize a node

func FromNode

func FromNode(node Node, hashToStringFn func(hash []byte) string) SerializableNode

FromNode recursively creates a SerializableNode from a Node hashToStringFn: funcion that converts a hash to a string

func (SerializableNode) JSON

func (sn SerializableNode) JSON() []byte

JSON converts the serializeable node into a Json

Jump to

Keyboard shortcuts

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