diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-14 01:15:23 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-14 01:15:23 +0800 |
commit | ce239333d529898edd8333637fd75c565e80a9ff (patch) | |
tree | 763f273cff09726bb16acf715d5ce0e2908e0b8f | |
parent | 0f3c25b26589f5667b618d6a91b73392d02ccd1e (diff) | |
download | dexon-ce239333d529898edd8333637fd75c565e80a9ff.tar.gz dexon-ce239333d529898edd8333637fd75c565e80a9ff.tar.zst dexon-ce239333d529898edd8333637fd75c565e80a9ff.zip |
Update balance label when mining
-rw-r--r-- | cmd/mist/assets/qml/views/wallet.qml | 11 | ||||
-rw-r--r-- | cmd/mist/gui.go | 4 | ||||
-rw-r--r-- | core/types/block.go | 2 | ||||
-rw-r--r-- | miner/worker.go | 3 |
4 files changed, 18 insertions, 2 deletions
diff --git a/cmd/mist/assets/qml/views/wallet.qml b/cmd/mist/assets/qml/views/wallet.qml index 545098284..838fa8749 100644 --- a/cmd/mist/assets/qml/views/wallet.qml +++ b/cmd/mist/assets/qml/views/wallet.qml @@ -15,6 +15,17 @@ Rectangle { objectName: "walletView" anchors.fill: parent + Label { + objectName: "balanceLabel" + visible: false + font.pixelSize: 10 + anchors.right: lastBlockLabel.left + anchors.rightMargin: 5 + onTextChanged: { + menuItem.secondaryTitle = text + } + } + function onReady() { setBalance() } diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 484cda5ff..c4ce1d463 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -412,7 +412,9 @@ func (gui *Gui) update() { switch ev := ev.(type) { case core.NewBlockEvent: gui.processBlock(ev.Block, false) - gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil) + //gui.setWalletValue(gui.eth.ChainManager().State().GetBalance(gui.address()), nil) + balance := ethutil.CurrencyToString(gui.eth.ChainManager().State().GetBalance(gui.address())) + gui.getObjectByName("balanceLabel").Set("text", fmt.Sprintf("%v", balance)) case core.TxPreEvent: tx := ev.Tx diff --git a/core/types/block.go b/core/types/block.go index a334c512e..562a21239 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -6,6 +6,7 @@ import ( "math/big" "sort" "time" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/rlp" @@ -175,6 +176,7 @@ func (self *Block) RlpDataForStorage() interface{} { // Header accessors (add as you need them) func (self *Block) Number() *big.Int { return self.header.Number } func (self *Block) NumberU64() uint64 { return self.header.Number.Uint64() } +func (self *Block) Nonce() []byte { return self.header.Nonce } func (self *Block) Bloom() []byte { return self.header.Bloom } func (self *Block) Coinbase() []byte { return self.header.Coinbase } func (self *Block) Time() int64 { return int64(self.header.Time) } diff --git a/miner/worker.go b/miner/worker.go index 9cb4ab76b..9244e06b9 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -127,7 +127,8 @@ out: func (self *worker) wait() { for { for work := range self.recv { - if self.current.block.Number().Uint64() == work.Number { + block := self.current.block + if block.Number().Uint64() == work.Number && block.Nonce() == nil { self.current.block.Header().Nonce = work.Nonce self.chain.InsertChain(types.Blocks{self.current.block}) |