From 1ab865a994758cef8a6bf75a3cc263f16a97d847 Mon Sep 17 00:00:00 2001 From: Maran Date: Tue, 27 May 2014 11:49:42 +0200 Subject: [PATCH] Adding new blocks on broadcast --- ethereal/assets/qml/wallet.qml | 13 +++++++++++-- ethereal/ui/gui.go | 7 ++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml index 911422f91..e59e85ab3 100644 --- a/ethereal/assets/qml/wallet.qml +++ b/ethereal/assets/qml/wallet.qml @@ -642,13 +642,22 @@ ApplicationWindow { txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract}) } - function addBlock(block) { + function addBlock(block, initial) { var txs = JSON.parse(block.transactions); var amount = 0 + if(initial == undefined){ + initial = false + } + if(txs != null){ amount = txs.length } - blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) + + 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) { diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index 7577de1fa..18e13d985 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -141,7 +141,7 @@ func (gui *Gui) setInitialBlockChain() { blk := gui.eth.BlockChain().GetBlock(sBlk) for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) { sBlk = blk.PrevHash - gui.processBlock(blk) + gui.processBlock(blk, true) } } @@ -163,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) { @@ -203,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) }