aboutsummaryrefslogtreecommitdiffstats
path: root/difftree/internal/radixmerkle/noder.go
diff options
context:
space:
mode:
authorAlberto Cortés <alcortesm@gmail.com>2016-11-23 15:20:32 +0100
committerGitHub <noreply@github.com>2016-11-23 15:20:32 +0100
commit844169a739fb8bf1f252d416f10d8c7034db9fe2 (patch)
tree426c3997042918698a9cc155c0dd5ae83d14bc1a /difftree/internal/radixmerkle/noder.go
parentce8c9645cc8ddb87abcf29c178ad6a784d43cbf3 (diff)
downloadgo-git-844169a739fb8bf1f252d416f10d8c7034db9fe2.tar.gz
difftree: merkletrie internal package with iterator (#133)
Diffstat (limited to 'difftree/internal/radixmerkle/noder.go')
-rw-r--r--difftree/internal/radixmerkle/noder.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/difftree/internal/radixmerkle/noder.go b/difftree/internal/radixmerkle/noder.go
new file mode 100644
index 0000000..3566657
--- /dev/null
+++ b/difftree/internal/radixmerkle/noder.go
@@ -0,0 +1,20 @@
+package merkletrie
+
+// The Noder interface is implemented by the elements of a Merkle Trie.
+type Noder interface {
+ // Hash returns the hash of the element.
+ Hash() []byte
+ // Key returns the key of the element.
+ Key() string
+ // Children returns the children of the element, sorted
+ // in reverse key alphabetical order.
+ Children() []Noder
+ // 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
+}