aboutsummaryrefslogtreecommitdiffstats
path: root/trie/trie.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-19 22:21:49 +0800
committerFelix Lange <fjl@twurst.com>2015-03-19 22:21:49 +0800
commitce063e8d9c2d26dd283a43b097903628225179ea (patch)
tree3bf88d349fd799285d75926f4486cb13f3cc7c70 /trie/trie.go
parente80dda605130479086bed363e395a102a89a574a (diff)
parent797bbce15ecf9ec76f6375a328c63eb9abcc3b5a (diff)
downloaddexon-ce063e8d9c2d26dd283a43b097903628225179ea.tar
dexon-ce063e8d9c2d26dd283a43b097903628225179ea.tar.gz
dexon-ce063e8d9c2d26dd283a43b097903628225179ea.tar.bz2
dexon-ce063e8d9c2d26dd283a43b097903628225179ea.tar.lz
dexon-ce063e8d9c2d26dd283a43b097903628225179ea.tar.xz
dexon-ce063e8d9c2d26dd283a43b097903628225179ea.tar.zst
dexon-ce063e8d9c2d26dd283a43b097903628225179ea.zip
Merge remote-tracking branch 'ethereum/conversion' into conversion
Diffstat (limited to 'trie/trie.go')
-rw-r--r--trie/trie.go19
1 files changed, 13 insertions, 6 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}
}