diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-08 19:07:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-08 19:07:21 +0800 |
commit | a953f3ec971fc6aebd28fed78d44778107ee4033 (patch) | |
tree | afe3217314fc03524bb94faf8c0923854deae042 /eth/backend.go | |
parent | 31b086f5111e4bd506a4ae468a9247bff24dd5cb (diff) | |
download | dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.tar dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.tar.gz dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.tar.bz2 dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.tar.lz dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.tar.xz dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.tar.zst dexon-a953f3ec971fc6aebd28fed78d44778107ee4033.zip |
Sync managed accounts to the network
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/eth/backend.go b/eth/backend.go index 6b60af1f1..317ee7373 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -436,6 +436,21 @@ func (self *Ethereum) txBroadcastLoop() { for obj := range self.txSub.Chan() { event := obj.(core.TxPreEvent) self.net.Broadcast("eth", TxMsg, []*types.Transaction{event.Tx}) + self.syncAccounts(event.Tx) + } +} + +// keep accounts synced up +func (self *Ethereum) syncAccounts(tx *types.Transaction) { + from, err := tx.From() + if err != nil { + return + } + + if self.accountManager.HasAccount(from.Bytes()) { + if self.chainManager.TxState().GetNonce(from) < tx.Nonce() { + self.chainManager.TxState().SetNonce(from, tx.Nonce()+1) + } } } |