mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core: never use so directly
This commit is contained in:
parent
4728db84aa
commit
fc3ee373ab
4 changed files with 26 additions and 11 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -71,8 +72,7 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A
|
|||
}
|
||||
|
||||
if !env.CanTransfer(caller.Address(), value) {
|
||||
caller.ReturnGas(gas, gasPrice)
|
||||
|
||||
fmt.Println("insuf", value)
|
||||
return nil, common.Address{}, ValueTransferErr("insufficient funds to transfer value. Req %v, has %v", value, env.Db().GetBalance(caller.Address()))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,24 @@ func (self *StateDB) RawDump() Dump {
|
|||
}
|
||||
dump.Accounts[common.Bytes2Hex(addr)] = account
|
||||
}
|
||||
for addr, stateObject := range self.stateObjects {
|
||||
account := DumpAccount{
|
||||
Balance: stateObject.data.Balance.String(),
|
||||
Nonce: stateObject.data.Nonce,
|
||||
Root: common.Bytes2Hex(stateObject.data.Root[:]),
|
||||
CodeHash: common.Bytes2Hex(stateObject.data.CodeHash),
|
||||
Code: common.Bytes2Hex(stateObject.Code(self.db)),
|
||||
Storage: make(map[string]string),
|
||||
}
|
||||
storageIt := stateObject.getTrie(self.db).Iterator()
|
||||
for storageIt.Next() {
|
||||
account.Storage[common.Bytes2Hex(self.trie.GetKey(storageIt.Key))] = common.Bytes2Hex(storageIt.Value)
|
||||
}
|
||||
for storageAddr, value := range stateObject.cachedStorage {
|
||||
account.Storage[storageAddr.Hex()] = value.Hex()
|
||||
}
|
||||
dump.Accounts[addr.Hex()] = account
|
||||
}
|
||||
return dump
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -410,8 +410,6 @@ func (s *StateDB) GetOrNewStateObject(address common.Address) *StateObject {
|
|||
if !s.localStateObjects[address] {
|
||||
stateObject = stateObject.Copy(s.db, s.MarkStateObjectDirty)
|
||||
s.SetOwnedStateObject(address, stateObject)
|
||||
//s.stateObjects[address] = stateObject
|
||||
//s.localStateObjects[address] = true
|
||||
}
|
||||
return stateObject
|
||||
}
|
||||
|
|
@ -421,8 +419,6 @@ func (s *StateDB) GetOrNewStateObject(address common.Address) *StateObject {
|
|||
stateObject.SetNonce(StartingNonce)
|
||||
|
||||
s.SetOwnedStateObject(address, stateObject)
|
||||
//s.stateObjects[address] = stateObject
|
||||
//s.localStateObjects[address] = true
|
||||
}
|
||||
return stateObject
|
||||
}
|
||||
|
|
@ -432,7 +428,6 @@ func (s *StateDB) GetStateObject(address common.Address) *StateObject {
|
|||
if account != nil {
|
||||
if s.stateObjects[address] == nil {
|
||||
s.SetStateObject(account)
|
||||
//s.stateObjects[address] = account
|
||||
}
|
||||
return account
|
||||
}
|
||||
|
|
@ -477,8 +472,8 @@ func (self *StateDB) CreateAccount(addr common.Address) vm.Account {
|
|||
}
|
||||
|
||||
func (self *StateDB) Set(state *StateDB) {
|
||||
self.lock.Lock()
|
||||
defer self.lock.Unlock()
|
||||
//self.lock.Lock()
|
||||
//defer self.lock.Unlock()
|
||||
|
||||
*self = *state
|
||||
/*
|
||||
|
|
@ -641,7 +636,7 @@ func IntermediateRoot(state *StateDB) common.Hash {
|
|||
}
|
||||
}
|
||||
}
|
||||
state.stateObjectsDirty = make(map[common.Address]struct{})
|
||||
//state.stateObjectsDirty = make(map[common.Address]struct{})
|
||||
return state.trie.Hash()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,9 @@ func (self *StateTransition) buyGas() error {
|
|||
}
|
||||
self.addGas(mgas)
|
||||
self.initialGas.Set(mgas)
|
||||
sender.SubBalance(mgval)
|
||||
|
||||
self.state.(*state.StateDB).SubBalance(sender.Address(), mgval)
|
||||
// sender.SubBalance(mgval)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue