inv message is used to relay one's knowledge of blocks and
txs to other clients in the Network. When a new Client connects to the Network, it first receives information about all the blocks in form of an
inv message, as a response to
getblocks messages. As there is no
gettx message, I presume the information about transactions is relayed in the last
inv response to
getblocks. Is that indeed the way the Standard Client operates, or does it just relay the
tx messages only when they arrive, making newly connected Clients wait to catch up with the information about the
One peer is picked at random to receive
inv messages which reference all the pending transactions that we know about and it doesn't, including the ones we created ourselves. The rest of the peers receive a
inv messages which only reference around 25% of the pending transactions that we know about and they don't, not including any of the ones we created.
A comment in the code explains that this "trickling" of transaction inventory is to protect privacy.
Edit: I just noticed this thread which also describes the process of advertising transactions. Luckily it agrees with my description here.
The process of announcing and sending data is the same for both transactions and blocks:
inv announces the hash of an object,
getdata is used to request the object itself, and
block are used to submit them.
getblocks is a step before this process: it requests the announcements of recent blocks via