diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-07 20:17:48 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-07 20:17:48 +0800 |
commit | fed3e6a808921fb8274b50043c5c39a24a1bbccf (patch) | |
tree | d632e95cfce78bd9a99a52bf7f30ee3ff980dfd3 /core/types | |
parent | 032ab665299d75bffc25260e8fa477ace19db06a (diff) | |
download | go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.gz go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.bz2 go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.lz go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.xz go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.tar.zst go-tangerine-fed3e6a808921fb8274b50043c5c39a24a1bbccf.zip |
Refactored ethutil.Config.Db out
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/block.go | 22 | ||||
-rw-r--r-- | core/types/derive_sha.go | 4 |
2 files changed, 14 insertions, 12 deletions
diff --git a/core/types/block.go b/core/types/block.go index 7e19d003f..be57e86a6 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -9,9 +9,7 @@ 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" ) type Header struct { @@ -168,16 +166,18 @@ func (self *Block) RlpDataForStorage() interface{} { } // Header accessors (add as you need them) -func (self *Block) Number() *big.Int { return self.header.Number } -func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() } -func (self *Block) Bloom() []byte { return self.header.Bloom } -func (self *Block) Coinbase() []byte { return self.header.Coinbase } -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) Trie() *ptrie.Trie { return ptrie.New(self.header.Root, ethutil.Config.Db) } +func (self *Block) Number() *big.Int { return self.header.Number } +func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() } +func (self *Block) Bloom() []byte { return self.header.Bloom } +func (self *Block) Coinbase() []byte { return self.header.Coinbase } +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) 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) Root() []byte { return self.header.Root } func (self *Block) SetRoot(root []byte) { self.header.Root = root } -func (self *Block) State() *state.StateDB { return state.New(self.Trie()) } func (self *Block) Size() ethutil.StorageSize { return ethutil.StorageSize(len(ethutil.Encode(self))) } // Implement pow.Block diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go index 0beb19670..0e286bd8b 100644 --- a/core/types/derive_sha.go +++ b/core/types/derive_sha.go @@ -1,6 +1,7 @@ package types import ( + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ptrie" ) @@ -11,7 +12,8 @@ type DerivableList interface { } func DeriveSha(list DerivableList) []byte { - trie := ptrie.New(nil, ethutil.Config.Db) + db, _ := ethdb.NewMemDatabase() + trie := ptrie.New(nil, db) for i := 0; i < list.Len(); i++ { trie.Update(ethutil.Encode(i), list.GetRlp(i)) } |