diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-05-25 22:40:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-25 22:40:51 +0800 |
commit | b7ff0d42e3adbacd6f4186c633cf73d06bd16324 (patch) | |
tree | 6abc554b343b8f68e76b7303e652f22f89e47d5e /core/tx_pool.go | |
parent | 07aae19e5da66ed404453e6be70ab84db516207b (diff) | |
parent | c98bce709c392f3b469f956b5f66f095a30a7e2b (diff) | |
download | dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.tar dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.tar.gz dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.tar.bz2 dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.tar.lz dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.tar.xz dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.tar.zst dexon-b7ff0d42e3adbacd6f4186c633cf73d06bd16324.zip |
Merge pull request #14515 from karalabe/golint-tooooolong
core: fix various golint warnings and errors
Diffstat (limited to 'core/tx_pool.go')
-rw-r--r-- | core/tx_pool.go | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/core/tx_pool.go b/core/tx_pool.go index a0373ca7d..6f67aaa0a 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -209,6 +209,7 @@ func (pool *TxPool) resetState() { pool.promoteExecutables(currentState) } +// Stop terminates the transaction pool. func (pool *TxPool) Stop() { pool.events.Unsubscribe() close(pool.quit) @@ -238,6 +239,7 @@ func (pool *TxPool) SetGasPrice(price *big.Int) { log.Info("Transaction pool price threshold updated", "price", price) } +// State returns the virtual managed state of the transaction pool. func (pool *TxPool) State() *state.ManagedState { pool.mu.RLock() defer pool.mu.RUnlock() @@ -850,22 +852,22 @@ func newTxSet() *txSet { // contains returns true if the set contains the given transaction hash // (not thread safe, should be called from a locked environment) -func (self *txSet) contains(hash common.Hash) bool { - _, ok := self.txMap[hash] +func (ts *txSet) contains(hash common.Hash) bool { + _, ok := ts.txMap[hash] return ok } // add adds a transaction hash to the set, then removes entries older than txSetDuration // (not thread safe, should be called from a locked environment) -func (self *txSet) add(hash common.Hash) { - self.txMap[hash] = struct{}{} +func (ts *txSet) add(hash common.Hash) { + ts.txMap[hash] = struct{}{} now := time.Now() - self.txOrd[self.addPtr] = txOrdType{hash: hash, time: now} - self.addPtr++ + ts.txOrd[ts.addPtr] = txOrdType{hash: hash, time: now} + ts.addPtr++ delBefore := now.Add(-txSetDuration) - for self.delPtr < self.addPtr && self.txOrd[self.delPtr].time.Before(delBefore) { - delete(self.txMap, self.txOrd[self.delPtr].hash) - delete(self.txOrd, self.delPtr) - self.delPtr++ + for ts.delPtr < ts.addPtr && ts.txOrd[ts.delPtr].time.Before(delBefore) { + delete(ts.txMap, ts.txOrd[ts.delPtr].hash) + delete(ts.txOrd, ts.delPtr) + ts.delPtr++ } } |