<p><a href="https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/net.cpp#L1505" rel="nofollow">ThreadMessageHandler2()</a> calls <a href="https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/main.cpp#L2826" rel="nofollow">SendMessages()</a> every 100 seconds, which causes <code>inv</code> messages to be sent to the client's peers.</p>

<p>One peer is <a href="https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/net.cpp#L1534" rel="nofollow">picked at random</a> to receive <code>inv</code> 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 <code>inv</code> messages which only reference <a href="https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/main.cpp#L2909" rel="nofollow">around 25%</a> of the pending transactions that we know about and they don't, not including any of the ones we created.</p>

<p>A comment in the code explains that this "trickling" of transaction inventory is to protect privacy.</p>

<p>Edit: I just noticed <a href="https://bitcointalk.org/index.php?topic=41730.0" rel="nofollow">this thread</a> which also describes the process of advertising transactions.  Luckily it agrees with my description here.</p>

CC BY-SA 3.0
2013-01-31T02:46:16.333Z
Sleep(100) means 100 milliseconds, not seconds.
Pieter Wuille
CC BY-SA 3.0
2012-03-25T17:42:48.040Z
2012-03-26T23:26:31.423Z
2012-03-26T23:26:31.423Z
Chris Moore
<p>The process of announcing and sending data is the same for both transactions and blocks: <code>inv</code> announces the hash of an object, <code>getdata</code> is used to request the object itself, and <code>tx</code> or <code>block</code> are used to submit them.</p>

<p><code>getblocks</code> is a step before this process: it requests the announcements of recent blocks via <code>inv</code>.</p>

CC BY-SA 3.0
2012-03-25T20:15:50.670Z
2012-03-25T20:15:50.670Z
Pieter Wuille
<p>The <a href="https://en.bitcoin.it/wiki/Protocol_specification#inv" rel="nofollow"><code>inv</code> message</a> is used to relay one's knowledge of blocks and <code>tx</code>s 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 <code>inv</code> message, as a response to <code>getblocks</code> messages. As there is no <code>gettx</code> message, I presume the information about transactions is  relayed in the last <code>inv</code> response to <code>getblocks</code>. Is that indeed the way the Standard Client operates, or does it just relay the <code>tx</code> messages only when they arrive, making newly connected Clients wait to catch up with the information about the <code>tx</code>s?</p>

<bitcoin-core><transactions><protocol><p2p><transaction-propagation>
When does the main client relay its knowledge of TXs in INV message?
ThePiachu
# When does the main client relay its knowledge of TXs in INV message?

(Asked by: username_0 on 2012-03-25)

The [`inv` message](https://en.bitcoin.it/wiki/Protocol_specification#inv) is used to relay one's knowledge of blocks and `tx`s 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 `tx`s?

**Tags:** bitcoin-core, transactions, protocol, p2p, transaction-propagation


---

## 2 answers

### Answer by username_1 on 2012-03-25. Score: 1 | Accepted answer

[ThreadMessageHandler2()](https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/net.cpp#L1505) calls [SendMessages()](https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/main.cpp#L2826) every 100 seconds, which causes `inv` messages to be sent to the client's peers.

One peer is [picked at random](https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/net.cpp#L1534) 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%](https://github.com/bitcoin/bitcoin/blob/a6b4a11385bf44e695c3e47cbd0de6e40eea0b23/src/main.cpp#L2909) 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](https://bitcointalk.org/index.php?topic=41730.0) which also describes the process of advertising transactions. Luckily it agrees with my description here.

> **Comments:**
> **username_2**: Sleep(100) means 100 milliseconds, not seconds.  

---

### Answer by username_2 on 2012-03-25. Score: 1

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 `tx` or `block` are used to submit them.

`getblocks` is a step before this process: it requests the announcements of recent blocks via `inv`.


---

