Commit 1037f881 authored by George Hotz's avatar George Hotz

shift >>2 for much smaller ram trie

parent ce93e39b
...@@ -44,7 +44,7 @@ func (kw PreimageKeyValueWriter) Delete(key []byte) error { ...@@ -44,7 +44,7 @@ func (kw PreimageKeyValueWriter) Delete(key []byte) error {
// full nodes / BRANCH_NODE have 17 values, each a hash // full nodes / BRANCH_NODE have 17 values, each a hash
// LEAF or EXTENSION nodes have 2 values, a path and value // LEAF or EXTENSION nodes have 2 values, a path and value
func parseNode(node common.Hash, depth int) { func parseNode(node common.Hash, depth int) {
if depth > 2 { if depth > 3 {
return return
} }
sprefix := strings.Repeat(" ", depth) sprefix := strings.Repeat(" ", depth)
...@@ -85,7 +85,7 @@ func RamToTrie(ram map[uint32](uint32)) common.Hash { ...@@ -85,7 +85,7 @@ func RamToTrie(ram map[uint32](uint32)) common.Hash {
for _, kv := range sram { for _, kv := range sram {
k, v := uint32(kv>>32), uint32(kv) k, v := uint32(kv>>32), uint32(kv)
//fmt.Printf("insert %x = %x\n", k, v) //fmt.Printf("insert %x = %x\n", k, v)
binary.BigEndian.PutUint32(tk, k) binary.BigEndian.PutUint32(tk, k>>2)
binary.BigEndian.PutUint32(tv, v) binary.BigEndian.PutUint32(tv, v)
mt.Update(tk, tv) mt.Update(tk, tv)
} }
......
package main package main
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"testing" "testing"
) )
...@@ -21,5 +22,6 @@ func TestTrie(t *testing.T) { ...@@ -21,5 +22,6 @@ func TestTrie(t *testing.T) {
root := RamToTrie(ram) root := RamToTrie(ram)
dat := SerializeTrie(root) dat := SerializeTrie(root)
fmt.Println("serialized length is", len(dat))
ioutil.WriteFile("/tmp/eth/ramtrie", dat, 0644) ioutil.WriteFile("/tmp/eth/ramtrie", dat, 0644)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment