mempool: Optimize pool double spend check.

This optimizes  `checkPoolDoubleSpend` to check the traversal position
first since it is more likely.
This commit is contained in:
Sarlor 2019-01-04 11:27:37 +08:00 committed by Dave Collins
parent 353f84e75a
commit bc63bf40d1

View File

@ -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
}