aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 6b60af1f1..c7a5b233f 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -195,7 +195,7 @@ func New(config *Config) (*Ethereum, error) {
eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.EventMux())
eth.pow = ethash.New(eth.chainManager)
- eth.txPool = core.NewTxPool(eth.EventMux())
+ eth.txPool = core.NewTxPool(eth.EventMux(), eth.chainManager.State)
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
eth.whisper = whisper.New()
@@ -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())
+ }
}
}