aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <obscuren@users.noreply.github.com>2014-10-30 04:10:04 +0800
committerJeffrey Wilcke <obscuren@users.noreply.github.com>2014-10-30 04:10:04 +0800
commitfa890c8c0140dac1e02038a6134db0d83bb85af9 (patch)
tree806fb16adbbec3bcd3ff93b8dfbdcdb73290fabb /cmd
parentce2ec1980bbc97fb9b2acc27c6249be1249fa44c (diff)
parent6b3f5fb82b0304f477a1c36b68b0d07232405aff (diff)
downloadgo-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar
go-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.gz
go-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.bz2
go-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.lz
go-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.xz
go-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.tar.zst
go-tangerine-fa890c8c0140dac1e02038a6134db0d83bb85af9.zip
Merge pull request #167 from fjl/feature/split-tx-event
Split TxEvent type for tx pre/post
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mist/gui.go51
1 files changed, 25 insertions, 26 deletions
diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go
index 45a99659b..e6da33475 100644
--- a/cmd/mist/gui.go
+++ b/cmd/mist/gui.go
@@ -408,7 +408,8 @@ func (gui *Gui) update() {
eth.ChainSyncEvent{},
eth.PeerListEvent{},
ethchain.NewBlockEvent{},
- ethchain.TxEvent{},
+ ethchain.TxPreEvent{},
+ ethchain.TxPostEvent{},
ethminer.Event{},
)
@@ -430,40 +431,38 @@ func (gui *Gui) update() {
gui.setWalletValue(gui.eth.StateManager().CurrentState().GetAccount(gui.address()).Balance(), nil)
}
- case ethchain.TxEvent:
+ case ethchain.TxPreEvent:
tx := ev.Tx
- if ev.Type == ethchain.TxPre {
- object := state.GetAccount(gui.address())
+ object := state.GetAccount(gui.address())
- if bytes.Compare(tx.Sender(), gui.address()) == 0 {
- unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
- } else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
- unconfirmedFunds.Add(unconfirmedFunds, tx.Value)
- }
-
- gui.setWalletValue(object.Balance(), unconfirmedFunds)
-
- gui.insertTransaction("pre", tx)
+ if bytes.Compare(tx.Sender(), gui.address()) == 0 {
+ unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
+ } else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
+ unconfirmedFunds.Add(unconfirmedFunds, tx.Value)
+ }
- } else if ev.Type == ethchain.TxPost {
- object := state.GetAccount(gui.address())
- if bytes.Compare(tx.Sender(), gui.address()) == 0 {
- object.SubAmount(tx.Value)
+ gui.setWalletValue(object.Balance(), unconfirmedFunds)
+ gui.insertTransaction("pre", tx)
- //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "send")
- gui.txDb.Put(tx.Hash(), tx.RlpEncode())
- } else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
- object.AddAmount(tx.Value)
+ case ethchain.TxPostEvent:
+ tx := ev.Tx
+ object := state.GetAccount(gui.address())
- //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "recv")
- gui.txDb.Put(tx.Hash(), tx.RlpEncode())
- }
+ if bytes.Compare(tx.Sender(), gui.address()) == 0 {
+ object.SubAmount(tx.Value)
- gui.setWalletValue(object.Balance(), nil)
+ //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "send")
+ gui.txDb.Put(tx.Hash(), tx.RlpEncode())
+ } else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
+ object.AddAmount(tx.Value)
- state.UpdateStateObject(object)
+ //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "recv")
+ gui.txDb.Put(tx.Hash(), tx.RlpEncode())
}
+ gui.setWalletValue(object.Balance(), nil)
+ state.UpdateStateObject(object)
+
// case object:
// gui.loadAddressBook()