diff options
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 { |