From 47a58b40cd4ba764c9823448687307bb4a80c697 Mon Sep 17 00:00:00 2001 From: Maran Date: Tue, 27 May 2014 10:29:39 +0200 Subject: [PATCH] Removed recursive function for loop --- ethereal/assets/qml/wallet.qml | 8 ++++---- ethereal/ui/gui.go | 15 ++++----------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml index f318ad1730..b467982c48 100644 --- a/ethereal/assets/qml/wallet.qml +++ b/ethereal/assets/qml/wallet.qml @@ -643,12 +643,12 @@ ApplicationWindow { } function addBlock(block) { - var objtt = JSON.parse(block.transactions); + var txs = JSON.parse(block.transactions); var amount = 0 - if(objtt != null){ - amount = objtt.length + if(txs != null){ + amount = txs.length } - blockModel.insert(0, {number: block.number, hash: block.hash, txs: objtt, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) + blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) } function addLog(str) { diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index 64c739c15b..7577de1fad 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -136,20 +136,13 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window { return gui.win } -func (gui *Gui) recursiveAdd(sBlk []byte) { +func (gui *Gui) setInitialBlockChain() { + sBlk := gui.eth.BlockChain().LastBlockHash blk := gui.eth.BlockChain().GetBlock(sBlk) - if blk != nil { - //ethutil.Config.Log.Infoln("Adding block", blk) + for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) { + sBlk = blk.PrevHash gui.processBlock(blk) - gui.recursiveAdd(blk.PrevHash) - return - } else { - //ethutil.Config.Log.Debugln("At Genesis, added all blocks to GUI") } - return -} -func (gui *Gui) setInitialBlockChain() { - gui.recursiveAdd(gui.eth.BlockChain().LastBlockHash) } func (gui *Gui) readPreviousTransactions() {