diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-05 01:47:23 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-06-05 01:47:23 +0800 |
commit | 45152dead5c6bc144f8ed51ed85d5ef64f783735 (patch) | |
tree | 48aa51432821a0d49ffa6d2a015c16f4867a1c63 /eth/backend.go | |
parent | 10fc73376789b1b016fbbd86df3b378df0238a0c (diff) | |
parent | 912cf7ba049e4bcd5e497c62bb7cb96e7502f1b9 (diff) | |
download | go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.tar go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.tar.gz go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.tar.bz2 go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.tar.lz go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.tar.xz go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.tar.zst go-tangerine-45152dead5c6bc144f8ed51ed85d5ef64f783735.zip |
Merge pull request #1181 from obscuren/txpool_fixes
cmd: transaction pool fixes and improvements
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/eth/backend.go b/eth/backend.go index 98939b1fa..3956dfcaa 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -198,7 +198,6 @@ type Ethereum struct { net *p2p.Server eventMux *event.TypeMux - txSub event.Subscription miner *miner.Miner // logger logger.LogSystem @@ -288,7 +287,7 @@ func New(config *Config) (*Ethereum, error) { eth.chainManager = core.NewChainManager(blockDb, stateDb, eth.pow, eth.EventMux()) eth.downloader = downloader.New(eth.EventMux(), eth.chainManager.HasBlock, eth.chainManager.GetBlock) eth.txPool = core.NewTxPool(eth.EventMux(), eth.chainManager.State, eth.chainManager.GasLimit) - eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.txPool, eth.chainManager, eth.EventMux()) + eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.chainManager, eth.EventMux()) eth.chainManager.SetProcessor(eth.blockProcessor) eth.miner = miner.New(eth, eth.EventMux(), eth.pow) eth.miner.SetGasPrice(config.GasPrice) @@ -470,10 +469,6 @@ func (s *Ethereum) Start() error { s.whisper.Start() } - // broadcast transactions - s.txSub = s.eventMux.Subscribe(core.TxPreEvent{}) - go s.txBroadcastLoop() - glog.V(logger.Info).Infoln("Server started") return nil } @@ -531,8 +526,6 @@ func (self *Ethereum) AddPeer(nodeURL string) error { } func (s *Ethereum) Stop() { - s.txSub.Unsubscribe() // quits txBroadcastLoop - s.net.Stop() s.protocolManager.Stop() s.chainManager.Stop() @@ -552,28 +545,6 @@ func (s *Ethereum) WaitForShutdown() { <-s.shutdownChan } -func (self *Ethereum) txBroadcastLoop() { - // automatically stops if unsubscribe - for obj := range self.txSub.Chan() { - event := obj.(core.TxPreEvent) - 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) { - if self.chainManager.TxState().GetNonce(from) < tx.Nonce() { - self.chainManager.TxState().SetNonce(from, tx.Nonce()) - } - } -} - // StartAutoDAG() spawns a go routine that checks the DAG every autoDAGcheckInterval // by default that is 10 times per epoch // in epoch n, if we past autoDAGepochHeight within-epoch blocks, |