<ol>
<li>During IBD, Bitcoin Core will only send getheaders to one peer. After IBD, it will send it to all on connection.</li>
<li>15 minutes. After that it will disconnect the peer if nothing is received.</li>
<li>As after timeout peers get disconnected, that opens up the slot for &quot;headers requesting peer&quot; to go to another one.</li>
</ol>

CC BY-SA 4.0
2021-07-22T12:00:44.390Z
Interesting. Isn't 15 minutes a pretty large timeout to wait? The node waits only for 2 seconds for receiving a response from "getdata", and disconnects the peer if it didn't send "block" within 2 seconds right?
satya
CC BY-SA 4.0
2021-07-22T12:12:13.697Z
What about "getdata" message? Does the node send "getdata" to all the peers that sent the corresponding "headers" or only one of them?
satya
CC BY-SA 4.0
2021-07-22T13:55:49.690Z
Bitcoin Core never requests the same block or transaction twice from the same peer. They all have timeouts that are tracked, and reassigned when the timeout expires.
Pieter Wuille
CC BY-SA 4.0
2021-07-22T14:33:56.187Z
Got it. I understand that after IBD, if a node gets the same "inv" message from 5 peers, then the node sends the same "getheaders" request to all 5 peers. It makes sense as "getheaders" and "headers" are pretty small messages and don't add too much communication.   Suppose the node gets the same "headers" from 5 peers. Will the node send "getdata" request to all 5 peers? Or will the node send "getdata" request to one peer, wait until the timer expires, and then send "getdata" to another peer?
satya
CC BY-SA 4.0
2021-07-22T15:11:12.787Z
Sorry, I meant to say: Bitcoin Core never requests the same transaction/block twice simultaneously, even from distinct peers. The existing request has to time out before it is asked elsewhere.
Pieter Wuille
CC BY-SA 4.0
2021-07-22T15:12:28.067Z
That's perfect :) Is the timeout for "getdata" also 15 minutes?
satya
CC BY-SA 4.0
2021-07-22T15:24:20.430Z
For transactions it is 2 minutes, but we don't disconnect on on timeout; just mark the peer as not having that tx, and asking another. For blocks I don't remember the details. You can look in https://github.com/bitcoin/bitcoin/tree/master/src/txrequest.h for some of the design choices for tx requesting. The block fetching code is spread out over a few places in net_processing.cpp.
Pieter Wuille
CC BY-SA 4.0
2021-07-22T04:10:11.403Z
2021-07-22T04:10:11.403Z
Pieter Wuille
<p>Suppose a node receives the same &quot;inv&quot; message from many peers.</p>
<ol>
<li><p>Will the node send &quot;getheaders&quot; requests to all the peers or only one of them?</p>
</li>
<li><p>Does the node keep a timer for getting the &quot;headers&quot; response from the peers? How big
is the timer?</p>
</li>
<li><p>Suppose the node sends &quot;getheaders&quot; requests to only one of its peers and the timer expires. How many other peers does the node then send &quot;getheaders&quot; requests to? Does the node store a map data structure <code>map&lt;&quot;inv&quot;, peer id from which the inv is received&gt;</code> to do this?</p>
</li>
</ol>

CC BY-SA 4.0
2021-07-22T00:24:46.287Z
Are you asking about Bitcoin Core (and which version?), or nodes in general? This is all local policy that each node/implementation can decide for itself.
Pieter Wuille
CC BY-SA 4.0
2021-07-22T01:31:42.877Z
@PieterWuille I'm asking about how Bitcoin Core (the latest version) implements it, and if there is a general node policy laid out somewhere that many implementations use.
satya
<bitcoin-core><synchronization><p2p>
What happens if a peer doesn't respond to "getheaders" or "getdata" on time?
satya
# What happens if a peer doesn't respond to "getheaders" or "getdata" on time?

(Asked by: username_0 on 2021-07-22)

Suppose a node receives the same "inv" message from many peers.

1. Will the node send "getheaders" requests to all the peers or only one of them?
2. Does the node keep a timer for getting the "headers" response from the peers? How big
   is the timer?
3. Suppose the node sends "getheaders" requests to only one of its peers and the timer expires. How many other peers does the node then send "getheaders" requests to? Does the node store a map data structure `map<"inv", peer id from which the inv is received>` to do this?

**Tags:** bitcoin-core, synchronization, p2p

> **Comments:**
> **username_1**: Are you asking about Bitcoin Core (and which version?), or nodes in general? This is all local policy that each node/implementation can decide for itself.  
> **username_0**: @username_1 I'm asking about how Bitcoin Core (the latest version) implements it, and if there is a general node policy laid out somewhere that many implementations use.  

---

## 1 answers

### Answer by username_1 on 2021-07-22. Score: 3 | Accepted answer

1. During IBD, Bitcoin Core will only send getheaders to one peer. After IBD, it will send it to all on connection.
2. 15 minutes. After that it will disconnect the peer if nothing is received.
3. As after timeout peers get disconnected, that opens up the slot for "headers requesting peer" to go to another one.

> **Comments:**
> **username_0**: Interesting. Isn't 15 minutes a pretty large timeout to wait? The node waits only for 2 seconds for receiving a response from "getdata", and disconnects the peer if it didn't send "block" within 2 seconds right?  
> **username_0**: What about "getdata" message? Does the node send "getdata" to all the peers that sent the corresponding "headers" or only one of them?  
> **username_1**: Bitcoin Core never requests the same block or transaction twice from the same peer. They all have timeouts that are tracked, and reassigned when the timeout expires.  
> **username_0**: Got it. I understand that after IBD, if a node gets the same "inv" message from 5 peers, then the node sends the same "getheaders" request to all 5 peers. It makes sense as "getheaders" and "headers" are pretty small messages and don't add too much communication.   Suppose the node gets the same "headers" from 5 peers. Will the node send "getdata" request to all 5 peers? Or will the node send "getdata" request to one peer, wait until the timer expires, and then send "getdata" to another peer?  
> **username_1**: Sorry, I meant to say: Bitcoin Core never requests the same transaction/block twice simultaneously, even from distinct peers. The existing request has to time out before it is asked elsewhere.  
> **username_0**: That's perfect :) Is the timeout for "getdata" also 15 minutes?  
> **username_1**: For transactions it is 2 minutes, but we don't disconnect on on timeout; just mark the peer as not having that tx, and asking another. For blocks I don't remember the details. You can look in https://github.com/bitcoin/bitcoin/tree/master/src/txrequest.h for some of the design choices for tx requesting. The block fetching code is spread out over a few places in net_processing.cpp.  

---

