Moved ethutil => common

This commit is contained in:
obscuren
2015-03-16 11:27:38 +01:00
parent 0b8f66ed9e
commit b523441361
116 changed files with 610 additions and 604 deletions

View File

@@ -4,7 +4,7 @@ import (
"bytes"
"math/big"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/trie"
)
@@ -17,7 +17,7 @@ var statelogger = logger.NewLogger("STATE")
// * Contracts
// * Accounts
type StateDB struct {
db ethutil.Database
db common.Database
trie *trie.SecureTrie
stateObjects map[string]*StateObject
@@ -28,8 +28,8 @@ type StateDB struct {
}
// Create a new state from a given trie
func New(root []byte, db ethutil.Database) *StateDB {
trie := trie.NewSecure(ethutil.CopyBytes(root), db)
func New(root []byte, db common.Database) *StateDB {
trie := trie.NewSecure(common.CopyBytes(root), db)
return &StateDB{db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: make(map[string]*big.Int)}
}
@@ -59,7 +59,7 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
return stateObject.balance
}
return ethutil.Big0
return common.Big0
}
func (self *StateDB) AddBalance(addr []byte, amount *big.Int) {
@@ -113,7 +113,7 @@ func (self *StateDB) SetCode(addr, code []byte) {
func (self *StateDB) SetState(addr, key []byte, value interface{}) {
stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetState(key, ethutil.NewValue(value))
stateObject.SetState(key, common.NewValue(value))
}
}
@@ -161,7 +161,7 @@ func (self *StateDB) DeleteStateObject(stateObject *StateObject) {
// Retrieve a state object given my the address. Nil if not found
func (self *StateDB) GetStateObject(addr []byte) *StateObject {
addr = ethutil.Address(addr)
addr = common.Address(addr)
stateObject := self.stateObjects[string(addr)]
if stateObject != nil {
@@ -195,7 +195,7 @@ func (self *StateDB) GetOrNewStateObject(addr []byte) *StateObject {
// Create a state object whether it exist in the trie or not
func (self *StateDB) NewStateObject(addr []byte) *StateObject {
addr = ethutil.Address(addr)
addr = common.Address(addr)
statelogger.Debugf("(+) %x\n", addr)