From bc63bf40d165a3e3b352a7fe2dca3683898e2bb7 Mon Sep 17 00:00:00 2001 From: Sarlor Date: Fri, 4 Jan 2019 11:27:37 +0800 Subject: [PATCH] mempool: Optimize pool double spend check. This optimizes `checkPoolDoubleSpend` to check the traversal position first since it is more likely. --- mempool/mempool.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index 855bdcf1..0b63857c 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -706,8 +706,7 @@ func (mp *TxPool) addTransaction(utxoView *blockchain.UtxoViewpoint, func (mp *TxPool) checkPoolDoubleSpend(tx *dcrutil.Tx, txType stake.TxType) error { for i, txIn := range tx.MsgTx().TxIn { // We don't care about double spends of stake bases. - if (txType == stake.TxTypeSSGen || txType == stake.TxTypeSSRtx) && - (i == 0) { + if i == 0 && (txType == stake.TxTypeSSGen || txType == stake.TxTypeSSRtx) { continue }