diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-26 07:47:04 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-26 07:47:04 +0800 |
commit | e16fd323e800297602a60b7a0e7b7897a55d2fa0 (patch) | |
tree | 1c27a3bc225af36d6b0b2117ba6b649cc3983110 /ethereal/ui/gui.go | |
parent | d0438ac10ab55cd12c1ab5ec3aaf0030185bf131 (diff) | |
download | go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.tar go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.tar.gz go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.tar.bz2 go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.tar.lz go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.tar.xz go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.tar.zst go-tangerine-e16fd323e800297602a60b7a0e7b7897a55d2fa0.zip |
Leverage the new watch & address:changed functionality
Diffstat (limited to 'ethereal/ui/gui.go')
-rw-r--r-- | ethereal/ui/gui.go | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index 80498d718..d3a179496 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -2,7 +2,6 @@ package ethui import ( "bytes" - "encoding/hex" "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" @@ -13,45 +12,6 @@ import ( "strings" ) -// Block interface exposed to QML -type Block struct { - Number int - Hash string -} - -type Tx struct { - Value, Hash, Address string - Contract bool -} - -type Key struct { - Address string -} - -type KeyRing struct { - Keys []interface{} -} - -func NewKeyRing(keys []interface{}) *KeyRing { - return &KeyRing{Keys: keys} -} - -func NewTxFromTransaction(tx *ethchain.Transaction) *Tx { - hash := hex.EncodeToString(tx.Hash()) - sender := hex.EncodeToString(tx.Recipient) - isContract := len(tx.Data) > 0 - - return &Tx{Hash: hash, Value: ethutil.CurrencyToString(tx.Value), Address: sender, Contract: isContract} -} - -// Creates a new QML Block from a chain block -func NewBlockFromBlock(block *ethchain.Block) *Block { - info := block.BlockInfo() - hash := hex.EncodeToString(block.Hash()) - - return &Block{Number: int(info.Number), Hash: hash} -} - type Gui struct { // The main application window win *qml.Window @@ -96,9 +56,9 @@ func (ui *Gui) Start(assetPath string) { // Register ethereum functions qml.RegisterTypes("Ethereum", 1, 0, []qml.TypeSpec{{ - Init: func(p *Block, obj qml.Object) { p.Number = 0; p.Hash = "" }, + Init: func(p *QBlock, obj qml.Object) { p.Number = 0; p.Hash = "" }, }, { - Init: func(p *Tx, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" }, + Init: func(p *QTx, obj qml.Object) { p.Value = ""; p.Hash = ""; p.Address = "" }, }}) ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", "0.1")) @@ -169,13 +129,13 @@ func (ui *Gui) readPreviousTransactions() { for it.Next() { tx := ethchain.NewTransactionFromBytes(it.Value()) - ui.win.Root().Call("addTx", NewTxFromTransaction(tx)) + ui.win.Root().Call("addTx", NewQTx(tx)) } it.Release() } func (ui *Gui) ProcessBlock(block *ethchain.Block) { - ui.win.Root().Call("addBlock", NewBlockFromBlock(block)) + ui.win.Root().Call("addBlock", NewQBlock(block)) } // Simple go routine function that updates the list of peers in the GUI @@ -193,13 +153,13 @@ func (ui *Gui) update() { if txMsg.Type == ethchain.TxPre { if bytes.Compare(tx.Sender(), ui.addr) == 0 { - ui.win.Root().Call("addTx", NewTxFromTransaction(tx)) + ui.win.Root().Call("addTx", NewQTx(tx)) ui.txDb.Put(tx.Hash(), tx.RlpEncode()) ui.eth.StateManager().GetAddrState(ui.addr).Nonce += 1 unconfirmedFunds.Sub(unconfirmedFunds, tx.Value) } else if bytes.Compare(tx.Recipient, ui.addr) == 0 { - ui.win.Root().Call("addTx", NewTxFromTransaction(tx)) + ui.win.Root().Call("addTx", NewQTx(tx)) ui.txDb.Put(tx.Hash(), tx.RlpEncode()) unconfirmedFunds.Add(unconfirmedFunds, tx.Value) |