<p>I don't see any delay here.  Looking at Bitcoin Core 0.9.3's code, I also don't see any code which would cause a delay as long as the node sending the <code>inv</code> responded to a <code>getdata</code> message immediately.</p>

<p>Transactions and blocks are placed into to separate queues in <a href="https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L3620-L3626" rel="nofollow">this code</a>:</p>

<pre><code>if (!fAlreadyHave) {
    if (!fImporting &amp;&amp; !fReindex) {
        if (inv.type == MSG_BLOCK)
            AddBlockToQueue(pfrom-&gt;GetId(), inv.hash);
        else
            pfrom-&gt;AskFor(inv);
</code></pre>

<p>Transactions and blocks are requested in <a href="https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L4380-4428" rel="nofollow">this long piece of code</a>, which I won't paste here.</p>

<p>I don't see any delays here for transaction requests.  I also tested this locally, and my node always immediately replied to a new <code>inv</code> message (type=tx) with a <code>getdata</code> message requesting that transaction.</p>

<p>There can be a delay in relaying transactions.  For example: node A sends an <code>inv</code> message for a new transaction to node B.  Node B gets the transaction, but then waits before sending an <code>inv</code> message to node C announcing that transaction.  You can see that in <a href="https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L4345-4361" rel="nofollow">this code</a> which includes the comment, "trickle out tx inv to protect privacy".</p>

CC BY-SA 3.0
2014-11-23T13:17:51.933Z
2014-11-23T13:17:51.933Z
David A. Harding
<p>I found that when a peer receives an <code>inv</code> message with type=block, it will immediately request that block or that block's headers with a <code>getdata</code> message or <code>getheaders</code> message. But if the peer receives an <code>inv</code> message with type=tx, it won't respond immediately.  For example:</p>

<pre><code>Node A  inv(tx)      Node B  |  Node A  inv(block)  Node B
        &lt;-----------         |          &lt;---------
                             |
        [delay]              |          [no delay]
                             | 
        getdata(tx)          |          getdata(block)
        -----------&gt;         |          ---------&gt;
</code></pre>

<p>Why is there a delay in requesting transactions but not a delay in requesting blocks? I'm guessing that relaying a transaction is less important than getting the most recent block to ensure the node is on the consensus best block chain.</p>

CC BY-SA 3.0
2014-11-22T17:27:34.710Z
There are too many pronouns in your question; I don't know which "it" is doing what.  Maybe use something like "node A" for one node and "node B" for the other node.  In particular, I'm having great difficulty understanding this part: "if it is inv.tx, it won't respond it until it will send messages using getdata."  If you can clarify, I'd be happy to answer.  Thanks!
David A. Harding
CC BY-SA 3.0
2014-11-23T07:05:10.207Z
sorry for my english,David. I mean: node A got an inv message, which inv.type is tx, node A won't respond this inv message immediately. But if the inv.type is block, node A would respond it immediately for requesting this block,using getdata message. Later, in node A's processing of sendmessage, it would respond the inv(type is tx) before it kept the inv in its processing of receiving messages. I am not sure my question is clear?
Eleven
<network><relay>
Does each peer prioritize inv(type=block) over inv(type=tx)?
Eleven
# Does each peer prioritize inv(type=block) over inv(type=tx)?

(Asked by: username_0 on 2014-11-22)

I found that when a peer receives an `inv` message with type=block, it will immediately request that block or that block's headers with a `getdata` message or `getheaders` message. But if the peer receives an `inv` message with type=tx, it won't respond immediately. For example:

```
Node A  inv(tx)      Node B  |  Node A  inv(block)  Node B
        <-----------         |          <---------
                             |
        [delay]              |          [no delay]
                             | 
        getdata(tx)          |          getdata(block)
        ----------->         |          --------->

```

Why is there a delay in requesting transactions but not a delay in requesting blocks? I'm guessing that relaying a transaction is less important than getting the most recent block to ensure the node is on the consensus best block chain.

**Tags:** network, relay

> **Comments:**
> **username_1**: There are too many pronouns in your question; I don't know which "it" is doing what.  Maybe use something like "node A" for one node and "node B" for the other node.  In particular, I'm having great difficulty understanding this part: "if it is inv.tx, it won't respond it until it will send messages using getdata."  If you can clarify, I'd be happy to answer.  Thanks!  
> **username_0**: sorry for my english,username_1. I mean: node A got an inv message, which inv.type is tx, node A won't respond this inv message immediately. But if the inv.type is block, node A would respond it immediately for requesting this block,using getdata message. Later, in node A's processing of sendmessage, it would respond the inv(type is tx) before it kept the inv in its processing of receiving messages. I am not sure my question is clear?  

---

## 1 answers

### Answer by username_1 on 2014-11-23. Score: 1

I don't see any delay here. Looking at Bitcoin Core 0.9.3's code, I also don't see any code which would cause a delay as long as the node sending the `inv` responded to a `getdata` message immediately.

Transactions and blocks are placed into to separate queues in [this code](https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L3620-L3626):

```
if (!fAlreadyHave) {
    if (!fImporting && !fReindex) {
        if (inv.type == MSG_BLOCK)
            AddBlockToQueue(pfrom->GetId(), inv.hash);
        else
            pfrom->AskFor(inv);

```

Transactions and blocks are requested in [this long piece of code](https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L4380-4428), which I won't paste here.

I don't see any delays here for transaction requests. I also tested this locally, and my node always immediately replied to a new `inv` message (type=tx) with a `getdata` message requesting that transaction.

There can be a delay in relaying transactions. For example: node A sends an `inv` message for a new transaction to node B. Node B gets the transaction, but then waits before sending an `inv` message to node C announcing that transaction. You can see that in [this code](https://github.com/bitcoin/bitcoin/blob/0.9.3/src/main.cpp#L4345-4361) which includes the comment, "trickle out tx inv to protect privacy".


---

