aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-24 01:35:36 +0800
committerobscuren <geffobscura@gmail.com>2014-12-24 01:35:36 +0800
commit780abaec988df302e0c98f1a35e9af35b5623746 (patch)
treedfd26765ec08d3df756730bb186639edb388b4ee /core
parent1054c155db8ac59b97b81fa7a7a20f2239eb1e82 (diff)
downloadgo-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.gz
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.bz2
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.lz
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.xz
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.tar.zst
go-tangerine-780abaec988df302e0c98f1a35e9af35b5623746.zip
Switched to new trie
Diffstat (limited to 'core')
-rw-r--r--core/block_manager.go1
-rw-r--r--core/genesis.go2
-rw-r--r--core/types/block.go4
-rw-r--r--core/types/derive_sha.go8
4 files changed, 8 insertions, 7 deletions
diff --git a/core/block_manager.go b/core/block_manager.go
index ef2113bfb..1b9da1269 100644
--- a/core/block_manager.go
+++ b/core/block_manager.go
@@ -217,6 +217,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
receiptSha := types.DeriveSha(receipts)
if bytes.Compare(receiptSha, header.ReceiptHash) != 0 {
+ fmt.Println("receipts", receipts)
err = fmt.Errorf("validating receipt root. received=%x got=%x", header.ReceiptHash, receiptSha)
return
}
diff --git a/core/genesis.go b/core/genesis.go
index 51afa314e..10b40516f 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -20,7 +20,7 @@ var EmptyShaList = crypto.Sha3(ethutil.Encode([]interface{}{}))
var EmptyListRoot = crypto.Sha3(ethutil.Encode(""))
func GenesisBlock() *types.Block {
- genesis := types.NewBlock(ZeroHash256, ZeroHash160, EmptyListRoot, big.NewInt(131072), crypto.Sha3(big.NewInt(42).Bytes()), "")
+ genesis := types.NewBlock(ZeroHash256, ZeroHash160, nil, big.NewInt(131072), crypto.Sha3(big.NewInt(42).Bytes()), "")
genesis.Header().Number = ethutil.Big0
genesis.Header().GasLimit = big.NewInt(1000000)
genesis.Header().GasUsed = ethutil.Big0
diff --git a/core/types/block.go b/core/types/block.go
index 940f2402e..054767d67 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -9,9 +9,9 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/ptrie"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/state"
- "github.com/ethereum/go-ethereum/trie"
)
type Header struct {
@@ -196,7 +196,7 @@ func (self *Block) Time() int64 { return int64(self.header.Time) }
func (self *Block) GasLimit() *big.Int { return self.header.GasLimit }
func (self *Block) GasUsed() *big.Int { return self.header.GasUsed }
func (self *Block) Hash() []byte { return self.header.Hash() }
-func (self *Block) Trie() *trie.Trie { return trie.New(ethutil.Config.Db, self.header.Root) }
+func (self *Block) Trie() *ptrie.Trie { return ptrie.New(self.header.Root, ethutil.Config.Db) }
func (self *Block) State() *state.StateDB { return state.New(self.Trie()) }
func (self *Block) Size() ethutil.StorageSize { return ethutil.StorageSize(len(ethutil.Encode(self))) }
diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go
index 1897ff198..0beb19670 100644
--- a/core/types/derive_sha.go
+++ b/core/types/derive_sha.go
@@ -2,7 +2,7 @@ package types
import (
"github.com/ethereum/go-ethereum/ethutil"
- "github.com/ethereum/go-ethereum/trie"
+ "github.com/ethereum/go-ethereum/ptrie"
)
type DerivableList interface {
@@ -11,10 +11,10 @@ type DerivableList interface {
}
func DeriveSha(list DerivableList) []byte {
- trie := trie.New(ethutil.Config.Db, "")
+ trie := ptrie.New(nil, ethutil.Config.Db)
for i := 0; i < list.Len(); i++ {
- trie.Update(string(ethutil.NewValue(i).Encode()), string(list.GetRlp(i)))
+ trie.Update(ethutil.Encode(i), list.GetRlp(i))
}
- return trie.GetRoot()
+ return trie.Root()
}