Refactored ethutil.Config.Db out
This commit is contained in:
@ -31,6 +31,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -103,7 +104,8 @@ func main() {
|
||||
}
|
||||
|
||||
// Leave the Println. This needs clean output for piping
|
||||
fmt.Printf("%s\n", block.State().Dump())
|
||||
statedb := state.New(block.Root(), ethereum.Db())
|
||||
fmt.Printf("%s\n", statedb.Dump())
|
||||
|
||||
fmt.Println(block)
|
||||
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/tests/helper"
|
||||
@ -41,8 +42,8 @@ type Account struct {
|
||||
Storage map[string]string
|
||||
}
|
||||
|
||||
func StateObjectFromAccount(addr string, account Account) *state.StateObject {
|
||||
obj := state.NewStateObject(ethutil.Hex2Bytes(addr))
|
||||
func StateObjectFromAccount(db ethutil.Database, addr string, account Account) *state.StateObject {
|
||||
obj := state.NewStateObject(ethutil.Hex2Bytes(addr), db)
|
||||
obj.SetBalance(ethutil.Big(account.Balance))
|
||||
|
||||
if ethutil.IsHex(account.Code) {
|
||||
@ -74,9 +75,10 @@ func RunVmTest(js string) (failed int) {
|
||||
}
|
||||
|
||||
for name, test := range tests {
|
||||
state := state.New(helper.NewTrie())
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
state := state.New(nil, db)
|
||||
for addr, account := range test.Pre {
|
||||
obj := StateObjectFromAccount(addr, account)
|
||||
obj := StateObjectFromAccount(db, addr, account)
|
||||
state.SetStateObject(obj)
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/ptrie"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/vm"
|
||||
)
|
||||
@ -63,7 +62,7 @@ func main() {
|
||||
ethutil.ReadConfig("/tmp/evmtest", "/tmp/evm", "")
|
||||
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
statedb := state.New(ptrie.New(nil, db))
|
||||
statedb := state.New(nil, db)
|
||||
sender := statedb.NewStateObject([]byte("sender"))
|
||||
receiver := statedb.NewStateObject([]byte("receiver"))
|
||||
//receiver.SetCode([]byte(*code))
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethutil"
|
||||
"github.com/ethereum/go-ethereum/logger"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
)
|
||||
|
||||
type plugin struct {
|
||||
@ -121,7 +122,7 @@ func (self *Gui) DumpState(hash, path string) {
|
||||
return
|
||||
}
|
||||
|
||||
stateDump = block.State().Dump()
|
||||
stateDump = state.New(block.Root(), self.eth.Db()).Dump()
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(path[7:], os.O_CREATE|os.O_RDWR, os.ModePerm)
|
||||
|
@ -117,18 +117,7 @@ func (gui *Gui) Start(assetPath string) {
|
||||
context.SetVar("eth", gui.uiLib)
|
||||
context.SetVar("shh", gui.whisper)
|
||||
|
||||
// Load the main QML interface
|
||||
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
||||
|
||||
var win *qml.Window
|
||||
var err error
|
||||
var addlog = false
|
||||
if len(data) == 0 {
|
||||
win, err = gui.showKeyImport(context)
|
||||
} else {
|
||||
win, err = gui.showWallet(context)
|
||||
addlog = true
|
||||
}
|
||||
win, err := gui.showWallet(context)
|
||||
if err != nil {
|
||||
guilogger.Errorln("asset not found: you can set an alternative asset path on the command line using option 'asset_path'", err)
|
||||
|
||||
@ -139,9 +128,7 @@ func (gui *Gui) Start(assetPath string) {
|
||||
win.Show()
|
||||
|
||||
// only add the gui guilogger after window is shown otherwise slider wont be shown
|
||||
if addlog {
|
||||
logger.AddLogSystem(gui)
|
||||
}
|
||||
logger.AddLogSystem(gui)
|
||||
win.Wait()
|
||||
|
||||
// need to silence gui guilogger after window closed otherwise logsystem hangs (but do not save loglevel)
|
||||
@ -275,7 +262,7 @@ func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
|
||||
}
|
||||
|
||||
var (
|
||||
ptx = xeth.NewJSTx(tx, gui.xeth.World().State())
|
||||
ptx = xeth.NewJSTx(tx)
|
||||
send = nameReg.Storage(tx.From())
|
||||
rec = nameReg.Storage(tx.To())
|
||||
s, r string
|
||||
|
@ -39,6 +39,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/miner"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/state"
|
||||
"github.com/ethereum/go-ethereum/xeth"
|
||||
)
|
||||
|
||||
@ -259,7 +260,8 @@ func BlockDo(ethereum *eth.Ethereum, hash []byte) error {
|
||||
|
||||
parent := ethereum.ChainManager().GetBlock(block.ParentHash())
|
||||
|
||||
_, err := ethereum.BlockProcessor().TransitionState(parent.State(), parent, block)
|
||||
statedb := state.New(parent.Root(), ethereum.Db())
|
||||
_, err := ethereum.BlockProcessor().TransitionState(statedb, parent, block)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user