Refactored to reactor. Fixes #42

This commit is contained in:
obscuren 2014-05-15 14:06:06 +02:00
parent 9ba3c6d1af
commit 3a2bddc160

View File

@ -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
func (gui *Gui) update() {
blockChan := make(chan ethutil.React, 1)
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)
gui.eth.TxPool().Subscribe(txChan)
reactor.Subscribe("newBlock", blockChan)
reactor.Subscribe("newTx:pre", txChan)
reactor.Subscribe("newTx:post", txChan)
state := gui.eth.StateManager().TransState()
@ -200,9 +201,9 @@ func (gui *Gui) update() {
}
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)
if bytes.Compare(tx.Sender(), gui.addr) == 0 && object.Nonce <= tx.Nonce {