From 17f0b1194232ebebc4e14f905e6e1d2d148aa5b6 Mon Sep 17 00:00:00 2001 From: changhong Date: Thu, 11 May 2017 09:55:48 +0800 Subject: core: typos and comments improve 1. fix typos 2. methods recevier of struct should be same 3. comments improve (cherry picked from commit 1ba979539582a00b7fd1a7c8a37a6852e59eac0d) --- core/tx_pool.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'core/tx_pool.go') diff --git a/core/tx_pool.go b/core/tx_pool.go index a0373ca7d..228563ed0 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -209,6 +209,7 @@ func (pool *TxPool) resetState() { pool.promoteExecutables(currentState) } +// Stop stops a TxPool 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 state of TxPool 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++ } } -- cgit v1.2.3 From c98bce709c392f3b469f956b5f66f095a30a7e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 25 May 2017 17:21:20 +0300 Subject: core: fix minor accidental typos and comment errors --- core/tx_pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/tx_pool.go') diff --git a/core/tx_pool.go b/core/tx_pool.go index 228563ed0..6f67aaa0a 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -209,7 +209,7 @@ func (pool *TxPool) resetState() { pool.promoteExecutables(currentState) } -// Stop stops a TxPool +// Stop terminates the transaction pool. func (pool *TxPool) Stop() { pool.events.Unsubscribe() close(pool.quit) @@ -239,7 +239,7 @@ func (pool *TxPool) SetGasPrice(price *big.Int) { log.Info("Transaction pool price threshold updated", "price", price) } -// State returns the state of TxPool +// State returns the virtual managed state of the transaction pool. func (pool *TxPool) State() *state.ManagedState { pool.mu.RLock() defer pool.mu.RUnlock() -- cgit v1.2.3