Merge branch 'develop' of github.com:ethereum/go-ethereum into develop

This commit is contained in:
Maran 2014-04-14 13:48:15 -04:00
commit 28a48f1d9a
4 changed files with 114 additions and 67 deletions

View File

@ -371,7 +371,18 @@ ApplicationWindow {
width: 800 width: 800
height: 600 height: 600
Item {
id: keyHandler
focus: true
Keys.onPressed: {
if (event.key == Qt.Key_Space) {
ui.next()
}
}
}
SplitView { SplitView {
anchors.fill: parent anchors.fill: parent
property var asmModel: ListModel { property var asmModel: ListModel {
id: asmModel id: asmModel
@ -416,59 +427,63 @@ ApplicationWindow {
} }
function setAsm(asm) { function setAsm(asm) {
//for(var i = 0; i < asm.length; i++) { asmModel.append({asm: asm})
asmModel.append({asm: asm}) }
//}
}
function clearAsm() {
asmModel.clear()
}
function setMem(mem) { function setInstruction(num) {
memModel.append({num: mem.num, value: mem.value}) asmTableView.selection.clear()
} asmTableView.selection.select(num-1)
function clearMem(){ }
memModel.clear()
}
function setStack(stack) { function clearAsm() {
stackModel.append({value: stack}) asmModel.clear()
} }
function clearStack() { function setMem(mem) {
stackModel.clear() memModel.append({num: mem.num, value: mem.value})
} }
function clearMem(){
memModel.clear()
}
function loadPlugin(name) { function setStack(stack) {
console.log("Loading plugin" + name) stackModel.append({value: stack})
mainView.addPlugin(name) }
}
function setWalletValue(value) { function clearStack() {
walletValueLabel.text = value stackModel.clear()
} }
function addTx(tx) { function loadPlugin(name) {
var isContract console.log("Loading plugin" + name)
if (tx.contract == true){ mainView.addPlugin(name)
isContract = "Yes" }
}else{
isContract = "No"
}
txModel.insert(0, {hash: tx.hash, address: tx.address, value: tx.value, contract: isContract})
}
function addBlock(block) { function setWalletValue(value) {
blockModel.insert(0, {number: block.number, hash: block.hash}) walletValueLabel.text = value
} }
function addLog(str) { function addTx(tx) {
if(str.len != 0) { var isContract
logModel.append({description: str}) if (tx.contract == true){
} isContract = "Yes"
}else{
isContract = "No"
} }
txModel.insert(0, {hash: tx.hash, address: tx.address, value: tx.value, contract: isContract})
}
function setPeers(text) { function addBlock(block) {
peerLabel.text = text blockModel.insert(0, {number: block.number, hash: block.hash})
}
function addLog(str) {
if(str.len != 0) {
logModel.append({description: str})
} }
} }
function setPeers(text) {
peerLabel.text = text
}
}

View File

@ -115,10 +115,12 @@ func (ui *Gui) Start(assetPath string) {
ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'") ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'")
panic(err) panic(err)
} }
ui.engine.LoadFile(uiLib.AssetPath("qml/transactions.qml"))
ui.win = component.CreateWindow(nil) ui.win = component.CreateWindow(nil)
uiLib.win = ui.win uiLib.win = ui.win
db := &Debugger{ui.win, make(chan bool)}
ui.lib.Db = db
uiLib.Db = db
// Register the ui as a block processor // Register the ui as a block processor
//ui.eth.BlockManager.SecondaryBlockProcessor = ui //ui.eth.BlockManager.SecondaryBlockProcessor = ui

View File

@ -15,6 +15,7 @@ type EthLib struct {
stateManager *ethchain.StateManager stateManager *ethchain.StateManager
blockChain *ethchain.BlockChain blockChain *ethchain.BlockChain
txPool *ethchain.TxPool txPool *ethchain.TxPool
Db *Debugger
} }
func (lib *EthLib) ImportAndSetPrivKey(privKey string) bool { func (lib *EthLib) ImportAndSetPrivKey(privKey string) bool {

View File

@ -16,6 +16,11 @@ import (
"strings" "strings"
) )
type memAddr struct {
Num string
Value string
}
// UI Library that has some basic functionality exposed // UI Library that has some basic functionality exposed
type UiLib struct { type UiLib struct {
engine *qml.Engine engine *qml.Engine
@ -24,6 +29,7 @@ type UiLib struct {
assetPath string assetPath string
// The main application window // The main application window
win *qml.Window win *qml.Window
Db *Debugger
} }
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib { func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
@ -89,15 +95,11 @@ func DefaultAssetPath() string {
return base return base
} }
type memAddr struct { func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) {
Num string
Value string
}
func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) (string, error) {
state := ui.eth.BlockChain().CurrentBlock.State() state := ui.eth.BlockChain().CurrentBlock.State()
asm, err := mutan.Compile(strings.NewReader(data), false) mainInput, _ := ethutil.PreProcess(data)
asm, err := mutan.Compile(strings.NewReader(mainInput), false)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
@ -126,21 +128,48 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string)
Diff: block.Difficulty, Diff: block.Difficulty,
TxData: nil, TxData: nil,
}) })
callerClosure.Call(vm, nil, func(op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) {
ui.win.Root().Call("clearMem")
ui.win.Root().Call("clearStack")
addr := 0 go func() {
for i := 0; i+32 <= mem.Len(); i += 32 { callerClosure.Call(vm, nil, ui.Db.halting)
ui.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])})
addr++
}
for _, val := range stack.Data() { state.Reset()
ui.win.Root().Call("setStack", val.String()) }()
} }
})
state.Reset() func (ui *UiLib) Next() {
ui.Db.Next()
return "", nil }
type Debugger struct {
win *qml.Window
N chan bool
}
func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) {
d.win.Root().Call("setInstruction", pc)
d.win.Root().Call("clearMem")
d.win.Root().Call("clearStack")
addr := 0
for i := 0; i+32 <= mem.Len(); i += 32 {
d.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])})
addr++
}
for _, val := range stack.Data() {
d.win.Root().Call("setStack", val.String())
}
out:
for {
select {
case <-d.N:
break out
default:
}
}
}
func (d *Debugger) Next() {
d.N <- true
} }