noder
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package noder provide an interface for defining nodes in amerkletrie, their hashes and their paths (a noders and itsancestors).
The hasher interface is easy to implement naively by elements thatalready have a hash, like git blobs and trees. More sophisticatedimplementations can implement the Equal function in exotic waysthough: for instance, comparing the modification time of directoriesin a filesystem.
Index¶
Constants¶
This section is empty.
Variables¶
var NoChildren = []Noder{}NoChildren represents the children of a noder without children.
Functions¶
This section is empty.
Types¶
typeEqual¶
Equal functions take two hashers and return if they are equal.
These functions are expected to be faster than reflect.Equal orreflect.DeepEqual because they can compare just the hash of theobjects, instead of their contents, so they are expected to be O(1).
typeHasher¶
type Hasher interface {Hash() []byte}Hasher interface is implemented by types that can tell youtheir hash.
typeNoder¶
type Noder interface {Hasherfmt.Stringer// for testing purposes// Name returns the name of an element (relative, not its full// path).Name()string// IsDir returns true if the element is a directory-like node or// false if it is a file-like node.IsDir()bool// Children returns the children of the element. Note that empty// directory-like noders and file-like noders will both return// NoChildren.Children() ([]Noder,error)// NumChildren returns the number of children this element has.//// This method is an optimization: the number of children is easily// calculated as the length of the value returned by the Children// method (above); yet, some implementations will be able to// implement NumChildren in O(1) while Children is usually more// complex.NumChildren() (int,error)Skip()bool}The Noder interface is implemented by the elements of a Merkle Trie.
There are two types of elements in a Merkle Trie:
- file-like nodes: they cannot have children.
- directory-like nodes: they can have 0 or more children and theirhash is calculated by combining their children hashes.
typePath¶
type Path []Noder
Path values represent a noder and its ancestors. The root goes firstand the actual final noder the path is referring to will be the last.
A path implements the Noder interface, redirecting all the interfacecalls to its final noder.
Paths build from an empty Noder slice are not valid paths and shouldnot be used.
func (Path)Compare¶
Compare returns -1, 0 or 1 if the path p is smaller, equal or biggerthan other, in "directory order"; for example:
"a" < "b""a/b/c/d/z" < "b""a/b/a" > "a/b"
func (Path)NumChildren¶
NumChildren returns the number of children the final noder of thepath has.