diff --git a/core/tx_pool.go b/core/tx_pool.go index 81efdbc358..5c5fab0ba0 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -1215,7 +1215,7 @@ func (pool *TxPool) addQiTxsLocked(txs types.Transactions) []error { for _, tx := range txs { pool.stateMu.RLock() - fee, _, _, err := ProcessQiTx(tx, pool.chain, false, true, pool.chain.CurrentBlock(), pool.currentState, &gp, new(uint64), pool.signer, pool.chainconfig.Location, *pool.chainconfig.ChainID, &etxRLimit, &etxPLimit) + fee, _, err := ProcessQiTx(tx, pool.chain, false, true, pool.chain.CurrentBlock(), pool.currentState, &gp, new(uint64), pool.signer, pool.chainconfig.Location, *pool.chainconfig.ChainID, &etxRLimit, &etxPLimit) if err != nil { pool.stateMu.RUnlock() pool.logger.WithFields(logrus.Fields{ @@ -1774,13 +1774,20 @@ func (pool *TxPool) reset(oldHead, newHead *types.WorkObject) { qiTxs = append(qiTxs, tx) } } - pool.mu.Unlock() // Don't lock the pool mutex while holding the qiMu lock - pool.qiMu.Lock() - pool.addQiTxsLocked(qiTxs) - pool.qiMu.Unlock() - pool.mu.Lock() - - pool.addTxsLocked(reinject, false) + var wg sync.WaitGroup + wg.Add(1) + go func() { + pool.addTxsLocked(reinject, false) + wg.Done() + }() + wg.Add(1) + go func() { + pool.qiMu.Lock() + pool.addQiTxsLocked(qiTxs) + pool.qiMu.Unlock() + wg.Done() + }() + wg.Wait() if pool.reOrgCounter == c_reorgCounterThreshold { pool.logger.WithField("time", common.PrettyDuration(time.Since(start))).Debug("Time taken to resetTxPool") } diff --git a/quai/handler.go b/quai/handler.go index 08c61ab7b2..9a00f9c80a 100644 --- a/quai/handler.go +++ b/quai/handler.go @@ -26,7 +26,7 @@ const ( // c_recentBlockReqTimeout is the timeout for the recent block requests cache c_recentBlockReqTimeout = 1 * time.Minute // c_broadcastTransactionsInterval is the interval for broadcasting transactions - c_broadcastTransactionsInterval = 5 * time.Second + c_broadcastTransactionsInterval = 2 * time.Second // c_maxTxBatchSize is the maximum number of transactions to broadcast at once c_maxTxBatchSize = 100 )