@@ -1669,6 +1669,7 @@ func (pool *TxPool) demoteUnexecutables() {
16691669 for _ , tx := range olds {
16701670 hash := tx .Hash ()
16711671 pool .all .Remove (hash )
1672+ pool .privateTxs .Remove (hash )
16721673 log .Trace ("Removed old pending transaction" , "hash" , hash )
16731674 }
16741675 // Drop all transactions that are too costly (low balance or out of gas), and queue any invalids back for later
@@ -1969,14 +1970,12 @@ func (t *txLookup) RemotesBelowTip(threshold *big.Int) types.Transactions {
19691970
19701971type timestampedTxHashSet struct {
19711972 lock sync.RWMutex
1972- hashes []common.Hash
19731973 timestamps map [common.Hash ]time.Time
19741974 ttl time.Duration
19751975}
19761976
19771977func newExpiringTxHashSet (ttl time.Duration ) * timestampedTxHashSet {
19781978 s := & timestampedTxHashSet {
1979- hashes : make ([]common.Hash , 0 ),
19801979 timestamps : make (map [common.Hash ]time.Time ),
19811980 ttl : ttl ,
19821981 }
@@ -1988,8 +1987,10 @@ func (s *timestampedTxHashSet) Add(hash common.Hash) {
19881987 s .lock .Lock ()
19891988 defer s .lock .Unlock ()
19901989
1991- s .hashes = append (s .hashes , hash )
1992- s .timestamps [hash ] = time .Now ().Add (s .ttl )
1990+ _ , ok := s .timestamps [hash ]
1991+ if ! ok {
1992+ s .timestamps [hash ] = time .Now ().Add (s .ttl )
1993+ }
19931994}
19941995
19951996func (s * timestampedTxHashSet ) Contains (hash common.Hash ) bool {
@@ -1999,25 +2000,26 @@ func (s *timestampedTxHashSet) Contains(hash common.Hash) bool {
19992000 return ok
20002001}
20012002
2002- func (s * timestampedTxHashSet ) prune ( ) {
2003+ func (s * timestampedTxHashSet ) Remove ( hash common. Hash ) {
20032004 s .lock .Lock ()
20042005 defer s .lock .Unlock ()
20052006
2006- var (
2007- count int
2008- now = time .Now ()
2009- )
2010- for _ , hash := range s .hashes {
2011- ts := s .timestamps [hash ]
2012- if ts .After (now ) {
2013- break
2014- }
2015-
2007+ _ , ok := s .timestamps [hash ]
2008+ if ok {
20162009 delete (s .timestamps , hash )
2017- count += 1
20182010 }
2011+ }
2012+
2013+ func (s * timestampedTxHashSet ) prune () {
2014+ s .lock .Lock ()
2015+ defer s .lock .Unlock ()
20192016
2020- s .hashes = s .hashes [count :]
2017+ now := time .Now ()
2018+ for hash , ts := range s .timestamps {
2019+ if ts .Before (now ) {
2020+ delete (s .timestamps , hash )
2021+ }
2022+ }
20212023}
20222024
20232025// numSlots calculates the number of slots needed for a single transaction.
0 commit comments