aboutsummaryrefslogtreecommitdiffstats
path: root/trie
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-19 22:07:33 +0800
committerobscuren <geffobscura@gmail.com>2015-03-19 22:07:33 +0800
commit554f20930abba7e55fb0dd2718a00c4bd066c973 (patch)
tree41ba92fa976a28547e4e7e43f7e80a4a4f680685 /trie
parent8b20c3cc976a149c64ef0ac2cabbe49e93ba739d (diff)
parenta756dbeb7b1027eb91130ecf8d5440dca8e738d8 (diff)
downloadgo-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.tar
go-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.tar.gz
go-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.tar.bz2
go-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.tar.lz
go-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.tar.xz
go-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.tar.zst
go-tangerine-554f20930abba7e55fb0dd2718a00c4bd066c973.zip
Merge branch 'develop' into rpcfrontier
Diffstat (limited to 'trie')
-rw-r--r--trie/trie.go19
-rw-r--r--trie/trie_test.go11
2 files changed, 23 insertions, 7 deletions
diff --git a/trie/trie.go b/trie/trie.go
index 1c1112a7f..d990338ee 100644
--- a/trie/trie.go
+++ b/trie/trie.go
@@ -6,8 +6,8 @@ import (
"fmt"
"sync"
- "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
)
func ParanoiaCheck(t1 *Trie, backend Backend) (bool, *Trie) {
@@ -302,14 +302,21 @@ func (self *Trie) mknode(value *common.Value) Node {
case 2:
// A value node may consists of 2 bytes.
if value.Get(0).Len() != 0 {
- return NewShortNode(self, CompactDecode(string(value.Get(0).Bytes())), self.mknode(value.Get(1)))
+ key := CompactDecode(string(value.Get(0).Bytes()))
+ if key[len(key)-1] == 16 {
+ return NewShortNode(self, key, &ValueNode{self, value.Get(1).Bytes()})
+ } else {
+ return NewShortNode(self, key, self.mknode(value.Get(1)))
+ }
}
case 17:
- fnode := NewFullNode(self)
- for i := 0; i < l; i++ {
- fnode.set(byte(i), self.mknode(value.Get(i)))
+ if len(value.Bytes()) != 17 {
+ fnode := NewFullNode(self)
+ for i := 0; i < 16; i++ {
+ fnode.set(byte(i), self.mknode(value.Get(i)))
+ }
+ return fnode
}
- return fnode
case 32:
return &HashNode{value.Bytes(), self}
}
diff --git a/trie/trie_test.go b/trie/trie_test.go
index 1393e0c97..16311aadf 100644
--- a/trie/trie_test.go
+++ b/trie/trie_test.go
@@ -5,8 +5,8 @@ import (
"fmt"
"testing"
- "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/crypto"
)
type Db map[string][]byte
@@ -32,6 +32,15 @@ func TestEmptyTrie(t *testing.T) {
}
}
+func TestNull(t *testing.T) {
+ trie := NewEmpty()
+
+ key := make([]byte, 32)
+ value := common.FromHex("0x823140710bf13990e4500136726d8b55")
+ trie.Update(key, value)
+ value = trie.Get(key)
+}
+
func TestInsert(t *testing.T) {
trie := NewEmpty()