aboutsummaryrefslogtreecommitdiffstats
path: root/core/transaction_pool.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-15 22:46:45 +0800
committerobscuren <geffobscura@gmail.com>2015-06-15 22:46:45 +0800
commite79cc42dfe36f6db61cebb37607f5bfe89e4cdcc (patch)
tree2162d4bcb3409ab843261ab1001c8217dc264d49 /core/transaction_pool.go
parent21fa29111b3cd12e3748fcb6310e6a18c5562f17 (diff)
downloaddexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.tar
dexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.tar.gz
dexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.tar.bz2
dexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.tar.lz
dexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.tar.xz
dexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.tar.zst
dexon-e79cc42dfe36f6db61cebb37607f5bfe89e4cdcc.zip
core: moved check for max queue to checkQueue
Moved the queue to check to the checkQueue method so no undeeded loops need to be initiated or sorting needs to happen twice.
Diffstat (limited to 'core/transaction_pool.go')
-rw-r--r--core/transaction_pool.go26
1 files changed, 10 insertions, 16 deletions
diff --git a/core/transaction_pool.go b/core/transaction_pool.go
index ce6fed1a9..e31f5c6b3 100644
--- a/core/transaction_pool.go
+++ b/core/transaction_pool.go
@@ -228,21 +228,6 @@ func (self *TxPool) queueTx(hash common.Hash, tx *types.Transaction) {
self.queue[from] = make(map[common.Hash]*types.Transaction)
}
self.queue[from][hash] = tx
-
- if len(self.queue[from]) > maxQueued {
- var (
- worstHash common.Hash
- worstNonce uint64
- )
- for hash, tx := range self.queue[from] {
- if tx.Nonce() > worstNonce {
- worstNonce = tx.Nonce()
- worstHash = hash
- }
- }
- glog.V(logger.Debug).Infof("Queued tx limit exceeded for %x. Removed worst nonce tx: %x\n", common.PP(from[:]), common.PP(worstHash[:]))
- delete(self.queue[from], worstHash)
- }
}
// addTx will add a transaction to the pending (processable queue) list of transactions
@@ -367,7 +352,16 @@ func (pool *TxPool) checkQueue() {
// Find the next consecutive nonce range starting at the
// current account nonce.
sort.Sort(addq)
- for _, e := range addq {
+ for i, e := range addq {
+ // start deleting the transactions from the queue if they exceed the limit
+ if i > maxQueued {
+ if glog.V(logger.Debug) {
+ glog.Infof("Queued tx limit exceeded for %s. Tx %s removed\n", common.PP(address[:]), common.PP(e.hash[:]))
+ }
+ delete(pool.queue[address], e.hash)
+ continue
+ }
+
if e.AccountNonce > guessedNonce {
break
}