Commit 3a2bddc1 authored by obscuren's avatar obscuren

Refactored to reactor. Fixes #42

parent 9ba3c6d1
...@@ -178,13 +178,14 @@ func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) { ...@@ -178,13 +178,14 @@ func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
// Simple go routine function that updates the list of peers in the GUI // Simple go routine function that updates the list of peers in the GUI
func (gui *Gui) update() { func (gui *Gui) update() {
blockChan := make(chan ethutil.React, 1)
reactor := gui.eth.Reactor() reactor := gui.eth.Reactor()
reactor.Subscribe("newBlock", blockChan) blockChan := make(chan ethutil.React, 1)
txChan := make(chan ethutil.React, 1)
txChan := make(chan ethchain.TxMsg, 1) reactor.Subscribe("newBlock", blockChan)
gui.eth.TxPool().Subscribe(txChan) reactor.Subscribe("newTx:pre", txChan)
reactor.Subscribe("newTx:post", txChan)
state := gui.eth.StateManager().TransState() state := gui.eth.StateManager().TransState()
...@@ -200,9 +201,9 @@ func (gui *Gui) update() { ...@@ -200,9 +201,9 @@ func (gui *Gui) update() {
} }
case txMsg := <-txChan: case txMsg := <-txChan:
tx := txMsg.Tx tx := txMsg.Resource.(*ethchain.Transaction)
if txMsg.Type == ethchain.TxPre { if txMsg.Event == "newTx:pre" {
object := state.GetAccount(gui.addr) object := state.GetAccount(gui.addr)
if bytes.Compare(tx.Sender(), gui.addr) == 0 && object.Nonce <= tx.Nonce { if bytes.Compare(tx.Sender(), gui.addr) == 0 && object.Nonce <= tx.Nonce {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment