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?

  • 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. Jul 22, 2021 at 0:24
  • @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
    Jul 22, 2021 at 1:31

1 Answer 1

  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.
  • 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
    Jul 22, 2021 at 12:00
  • What about "getdata" message? Does the node send "getdata" to all the peers that sent the corresponding "headers" or only one of them?
    – satya
    Jul 22, 2021 at 12:12
  • 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. Jul 22, 2021 at 13:55
  • 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
    Jul 22, 2021 at 14:33
  • 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. Jul 22, 2021 at 15:11

Your Answer

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

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