As proposed in the IRC meeting from august 4th (see http://www.erisian.com.au/meetbot/bitcoin-core-dev/2016/bitcoin-core-dev.2016-08-04-19.00.log.html), this changes the logic to never store witness transactions (or transactions whose witness data was stripped) in the rejection cache.
As an optimization, only double check for witness invalidity if the transaction has no witness. This changes the meaning for state.CorruptionPossible() for transactions from “witness possibly invalidated” to “witness stripped”. This is faster (no need for 3 script checks) and simpler for the DoS logic.
This also removes the special logic to not assign DoS for witness failures for non-witness peers. That logic already exists in more generic form, through the non-mandatory script verify flags.
See also #8279.