Author

Topic: How is bitcoind “shy” when exchanging `version` packets? (Read 191 times)

newbie
Activity: 16
Merit: 12
If you initiate the connection, then you send a version right away, and so when you receive a version in return, you don't want to send another one. If the peer initiates the connection, then you ignore them until you receive a version, and when you do, you then need to respond with a version of your own. That's what that if statement is about.

Very old versions would immediately send a version as soon as the TCP connection was opened, regardless of whether it was incoming or outgoing. The comment is maybe a little confusing because it's sort-of talking about changing this ancient behavior.

So basically at that point I know that I received a version, the question is whether I should send one back or not and that depends on who opened the connection (because if I did then I already sent one). Makes sense and is compliant with the code, but got nothing to do with shyness (letting the other peer send one first). So yeah I guess the comment is just kinda confusing Smiley Thanks a lot
administrator
Activity: 5222
Merit: 13032
If you initiate the connection, then you send a version right away, and so when you receive a version in return, you don't want to send another one. If the peer initiates the connection, then you ignore them until you receive a version, and when you do, you then need to respond with a version of your own. That's what that if statement is about.

Very old versions would immediately send a version as soon as the TCP connection was opened, regardless of whether it was incoming or outgoing. The comment is maybe a little confusing because it's sort-of talking about changing this ancient behavior.
newbie
Activity: 16
Merit: 12
Hello,

I posted this question on bitcoin.SE so I'll just leave the link here if anyone wants to answer that, but paste the full question here as well.

Link: https://bitcoin.stackexchange.com/questions/79991/how-is-bitcoind-shy-when-exchanging-version-packets

Question:

I am referring to this line of code: https://github.com/bitcoin/bitcoin/blob/be992701b018f256db6d64786624be4cb60d8975/src/net_processing.cpp#L1699

I understand the logic behind not sending a version packet to a newly accepted connection unless they send one first, but the code I linked to does not quite do that, or does it?

At that point we are already inside an if block which verifies that the command received is "version", so the peer has already sent us a version packet, irrespective of who initiated the connection. Am I missing something?

Jump to: