1

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.

2
  • 2
    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! Nov 22, 2014 at 17:27
  • 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
    Nov 23, 2014 at 7:05

1 Answer 1

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:

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, 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 which includes the comment, "trickle out tx inv to protect privacy".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.