Minor update

This commit is contained in:
obscuren
2014-01-08 23:43:20 +01:00
parent 9f42835a02
commit 92b6667bd1
7 changed files with 126 additions and 44 deletions

22
trie.go
View File

@ -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 {