Could anyone explain in simple words what does the reference client do when it receives a orphan, stale or best-chain block regarding sending "inv", "block" and "getdata" commands? An interaction diagram or concise description would be very useful.
The block forwarding logic is spread all over main.cpp source code.
A complete answer should allow to respond these simple questions with true/false:
a. An orphan block received from a peer is not announced to the remaining peers until the parents are found ("inv" command not sent immediately).
b. A stale block (not in the best chain) received from a peer is not announced to the remaining peers until it becomes part of the best chain ("inv" command not sent immediately).
c. Some blocks are forwarded even if they are not requested by peers ("block" command issued even if "getdata" not received). Which blocks?
d. Orphan blocks can be requested by peers using "getdata".
e. Stale blocks can be requested by peers using "getdata".
f. Nodes request whatever block it's announced by a peer "inv" command for which they don't have the hash, being stale, orphan or invalid.
This link https://bitcointalk.org/index.php?topic=41729.0 describes the interaction, but it's terribly complicated. Can it be described in more simple words?