Fixed tx nonce

This commit is contained in:
obscuren 2014-04-30 17:13:12 +02:00
parent c5481b7654
commit da7828f336

View File

@ -146,17 +146,20 @@ func (ui *Gui) update() {
account := ui.eth.StateManager().GetAddrState(ui.addr).Object account := ui.eth.StateManager().GetAddrState(ui.addr).Object
unconfirmedFunds := new(big.Int) unconfirmedFunds := new(big.Int)
ui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(account.Amount))) ui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(account.Amount)))
addrState := ui.eth.StateManager().GetAddrState(ui.addr)
for { for {
select { select {
case txMsg := <-txChan: case txMsg := <-txChan:
tx := txMsg.Tx tx := txMsg.Tx
if txMsg.Type == ethchain.TxPre { if txMsg.Type == ethchain.TxPre {
if bytes.Compare(tx.Sender(), ui.addr) == 0 { if bytes.Compare(tx.Sender(), ui.addr) == 0 && addrState.Nonce <= tx.Nonce {
ui.win.Root().Call("addTx", NewQTx(tx)) ui.win.Root().Call("addTx", NewQTx(tx))
ui.txDb.Put(tx.Hash(), tx.RlpEncode()) ui.txDb.Put(tx.Hash(), tx.RlpEncode())
ui.eth.StateManager().GetAddrState(ui.addr).Nonce += 1 addrState.Nonce += 1
unconfirmedFunds.Sub(unconfirmedFunds, tx.Value) unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
} else if bytes.Compare(tx.Recipient, ui.addr) == 0 { } else if bytes.Compare(tx.Recipient, ui.addr) == 0 {
ui.win.Root().Call("addTx", NewQTx(tx)) ui.win.Root().Call("addTx", NewQTx(tx))