2
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->setInventoryKnown.count(inv))
and
if (pto->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->setInventoryKnown.count(inv)) only checks if entry is known to target peer and if (pto->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 wasn't arguing (although maybe I was unclear) that the insert was useless, only that checking the result of the insert was useless because (as Aliakbar Ahmadi noticed) the result will always be
true. Does my answer need updating? – Christopher Gurnee – 2015-06-10T19:56:37.270Ah. Right. The if itself is useless but not the expression within the if. Fair enough. :) – Jonas Schnelli – 2015-06-10T20:02:55.877