diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-27 19:31:57 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-27 19:31:57 +0800 |
commit | 2be98230105ef402d26e8726cec2240770a9837f (patch) | |
tree | bbd3c9eef4cba01c95ed09f13d821c7d9a37dff6 /ethereal | |
parent | 47417506c377dd0848739473fa14a51708b6a034 (diff) | |
parent | 6fe42f007c6f4816de88a2c4aad10754036d41b8 (diff) | |
download | dexon-2be98230105ef402d26e8726cec2240770a9837f.tar.gz dexon-2be98230105ef402d26e8726cec2240770a9837f.tar.zst dexon-2be98230105ef402d26e8726cec2240770a9837f.zip |
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Conflicts:
ethereal/assets/qml/wallet.qml
Diffstat (limited to 'ethereal')
-rw-r--r-- | ethereal/assets/qml/wallet.qml | 160 | ||||
-rw-r--r-- | ethereal/ui/gui.go | 16 |
2 files changed, 154 insertions, 22 deletions
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml index 4aa22dddc..3063bb10d 100644 --- a/ethereal/assets/qml/wallet.qml +++ b/ethereal/assets/qml/wallet.qml @@ -6,6 +6,7 @@ import QtQuick.Window 2.1; import QtQuick.Controls.Styles 1.1 import Ethereum 1.0 + ApplicationWindow { id: root @@ -202,16 +203,14 @@ ApplicationWindow { anchors.bottom: logView.top TableViewColumn{ role: "number" ; title: "#" ; width: 100 } TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 } + TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 } model: blockModel - /* - onDoubleClicked: { - popup.visible = true - popup.block = eth.getBlock(blockModel.get(row).hash) - popup.hashLabel.text = popup.block.hash - } - */ + onDoubleClicked: { + popup.visible = true + popup.setDetails(blockModel.get(row)) + } } property var logModel: ListModel { @@ -308,6 +307,15 @@ ApplicationWindow { */ Button { + property var enabled: true + id: debuggerWindow + onClicked: { + ui.startDebugger() + } + text: "Debugger" + } + + Button { id: importAppButton anchors.left: debuggerWindow.right anchors.leftMargin: 5 @@ -341,10 +349,107 @@ ApplicationWindow { id: popup visible: false property var block - Label { - id: hashLabel - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter + width: 800 + height: 280 + x: root.x + y: root.y + root.height + Component{ + id: blockDetailsDelegate + Rectangle { + color: "#252525" + width: popup.width + height: 200 + Column { + anchors.leftMargin: 10 + anchors.topMargin: 5 + anchors.top: parent.top + anchors.left: parent.left + Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"} + Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"} + Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"} + Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"} + } + } + } + ListView { + model: singleBlock + delegate: blockDetailsDelegate + anchors.top: parent.top + height: 70 + anchors.leftMargin: 20 + id: listViewThing + Layout.maximumHeight: 40 + } + TableView { + id: txView + anchors.top: listViewThing.bottom + anchors.topMargin: 50 + width: parent.width + + TableViewColumn{width: 90; role: "value" ; title: "Value" } + TableViewColumn{width: 200; role: "hash" ; title: "Hash" } + TableViewColumn{width: 200; role: "sender" ; title: "Sender" } + TableViewColumn{width: 200;role: "address" ; title: "Receiver" } + TableViewColumn{width: 60; role: "gas" ; title: "Gas" } + TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" } + TableViewColumn{width: 60; role: "isContract" ; title: "Contract" } + + model: transactionModel + onClicked: { + var tx = transactionModel.get(row) + if(tx.data) { + popup.showContractData(tx.data) + }else{ + popup.height = 230 + } + } + } + function showContractData(data) { + contractData.text = data + popup.height = 400 + } + Rectangle { + width: popup.width + height: 300 + anchors.left: listViewThing.left + anchors.top: txView.bottom + Label { + text: "<h4>Contract data</h4>" + anchors.top: parent.top + anchors.left: parent.left + id: contractLabel + anchors.leftMargin: 10 + } + TextArea { + id: contractData + text: "Contract" + anchors.top: contractLabel.bottom + anchors.left: parent.left + wrapMode: Text.Wrap + width: parent.width - 30 + height: 80 + anchors.leftMargin: 10 + } + } + property var transactionModel: ListModel { + id: transactionModel + } + property var singleBlock: ListModel { + id: singleBlock + } + function setDetails(block){ + singleBlock.set(0,block) + popup.height = 230 + transactionModel.clear() + if(block.txs != undefined){ + for(var i = 0; i < block.txs.count; ++i) { + transactionModel.insert(0, block.txs.get(i)) + } + if(block.txs.get(0).data){ + popup.showContractData(block.txs.get(0).data) + } + } + txView.forceActiveFocus() } } @@ -462,6 +567,7 @@ ApplicationWindow { SplitView { orientation: Qt.Horizontal + id: debugSplitView TableView { property var debuggerLog: ListModel { id: debuggerLog @@ -475,7 +581,7 @@ ApplicationWindow { } height: parent.height/2 width: parent.width - TableViewColumn{ role: "value" ; title: "Stack" ; width: 300 } + TableViewColumn{ role: "value" ; title: "Stack" ; width: debugSplitView.width } model: stackModel } } @@ -548,8 +654,22 @@ ApplicationWindow { txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract}) } - function addBlock(block) { - blockModel.insert(0, {number: block.number, hash: block.hash}) + function addBlock(block, initial) { + var txs = JSON.parse(block.transactions); + var amount = 0 + if(initial == undefined){ + initial = false + } + + if(txs != null){ + amount = txs.length + } + + if(initial){ + blockModel.append({number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) + }else{ + blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) + } } function addLog(str) { @@ -561,4 +681,16 @@ ApplicationWindow { function setPeers(text) { peerLabel.text = text } + function convertToPretty(unixTs){ + var a = new Date(unixTs*1000); + var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; + var year = a.getFullYear(); + var month = months[a.getMonth()]; + var date = a.getDate(); + var hour = a.getHours(); + var min = a.getMinutes(); + var sec = a.getSeconds(); + var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ; + return time; + } } diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index ca6da5c49..b49fafac1 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -136,14 +136,13 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window { return gui.win } - func (gui *Gui) setInitialBlockChain() { - // Load previous 10 blocks - chain := gui.eth.BlockChain().GetChain(gui.eth.BlockChain().CurrentBlock.Hash(), 10) - for _, block := range chain { - gui.processBlock(block) + sBlk := gui.eth.BlockChain().LastBlockHash + blk := gui.eth.BlockChain().GetBlock(sBlk) + for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) { + sBlk = blk.PrevHash + gui.processBlock(blk, true) } - } func (gui *Gui) readPreviousTransactions() { @@ -164,8 +163,8 @@ func (gui *Gui) readPreviousTransactions() { it.Release() } -func (gui *Gui) processBlock(block *ethchain.Block) { - gui.win.Root().Call("addBlock", ethpub.NewPBlock(block)) +func (gui *Gui) processBlock(block *ethchain.Block, initial bool) { + gui.win.Root().Call("addBlock", ethpub.NewPBlock(block), initial) } func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) { @@ -204,6 +203,7 @@ func (gui *Gui) update() { select { case b := <-blockChan: block := b.Resource.(*ethchain.Block) + gui.processBlock(block, false) if bytes.Compare(block.Coinbase, gui.addr) == 0 { gui.setWalletValue(gui.eth.StateManager().CurrentState().GetAccount(gui.addr).Amount, nil) } |