diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-09 06:43:20 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-09 06:43:20 +0800 |
commit | 92b6667bd1cf7aad4a00331d761d8a92b03a7cae (patch) | |
tree | 01eba885b03343e576785082d90e3f786cf48261 /trie.go | |
parent | 9f42835a0204ba2508895c1d259340bcda843974 (diff) | |
download | go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.tar go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.tar.gz go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.tar.bz2 go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.tar.lz go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.tar.xz go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.tar.zst go-tangerine-92b6667bd1cf7aad4a00331d761d8a92b03a7cae.zip |
Minor update
Diffstat (limited to 'trie.go')
-rw-r--r-- | trie.go | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -36,6 +36,8 @@ func DecodeNode(data []byte) []string { } return strSlice + } else { + fmt.Printf("It wasn't a []. It's a %T\n", dec) } return nil @@ -70,16 +72,6 @@ func (t *Trie) Get(key string) string { * State functions (shouldn't be needed directly). */ -// Wrapper around the regular db "Put" which generates a key and value -func (t *Trie) Put(node interface{}) []byte { - enc := Encode(node) - sha := Sha256Bin(enc) - - t.db.Put([]byte(sha), enc) - - return sha -} - // Helper function for printing a node (using fetch, decode and slice printing) func (t *Trie) PrintNode(n string) { data, _ := t.db.Get([]byte(n)) @@ -133,6 +125,16 @@ func (t *Trie) UpdateState(node string, key []int, value string) string { return "" } +// Wrapper around the regular db "Put" which generates a key and value +func (t *Trie) Put(node interface{}) []byte { + enc := Encode(node) + var sha []byte + sha = Sha256Bin(enc) + + t.db.Put([]byte(sha), enc) + + return sha +} func (t *Trie) InsertState(node string, key []int, value string) string { if len(key) == 0 { |