diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-04 04:22:20 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-04 04:43:23 +0800 |
commit | d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8 (patch) | |
tree | ec8f89f562417a379c45c25d58b5de9b45bc0b04 /eth/backend.go | |
parent | 5197aed7dbba2ac19d99221efe33fede82007f5d (diff) | |
download | go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.tar go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.tar.gz go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.tar.bz2 go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.tar.lz go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.tar.xz go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.tar.zst go-tangerine-d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8.zip |
core, eth, miner: moved nonce management to tx pool.
Removed the managed tx state from the chain manager to the transaction
pool where it's much easier to keep track of nonces (and manage them).
The transaction pool now also uses the queue and pending txs differently
where queued txs are now moved over to the pending queue (i.e. txs ready
for processing and propagation).
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/eth/backend.go b/eth/backend.go index 724763a52..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 @@ -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, |