Two if's before sending an inventory message Going through main.cpp I couldn't completely understand the purpose of a double barrier coded as if-statements:
I'm referring to ...

if (pto-&gt;setInventoryKnown.count(inv))

and

if (pto-&gt;setInventoryKnown.insert(inv).second)

What is the idea behind checking if an inventory is known to the target peer twice? I'm aware that if (pto-&gt;setInventoryKnown.count(inv)) only checks if entry is known to target peer and if (pto-&gt;setInventoryKnown.insert(inv).second) inserts the inventory item after checking its uniqueness.I mean couldn't one just use only one if-statement combining?
I don't see any reason for the second if statement, either. I'm not speaking from any form of authority here, but it looks like a (tiny) efficiency bug to me.

The second if statement has been around since the first commit. The first if statement was inserted about a year later when "trickling" of tx inv messages was added, presumably to check the set membership earlier to avoid running through the trickling logic when it's not necessary. I'd guess that the removal of the second if was simply overlooked.