3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-11 17:55:53 +00:00

Change the order of the messages in the version handshake. This fixes connections to BitCoin nodes beyond v0.30.20.2 which are "shy", that is, they do not announce their version on accepting a connection. The intent of that change is to make port scanning harder, though it is questionable whether this really is effective.

This commit is contained in:
Mike Hearn 2011-03-25 20:41:26 +00:00
parent 513eff26f9
commit bb017a5dab

View File

@ -73,11 +73,13 @@ public class NetworkConnection {
out = socket.getOutputStream();
in = socket.getInputStream();
// Announce ourselves. This has to come first to connect to clients beyond v0.30.20.2 which wait to hear
// from us until they send their version message back.
writeMessage(MSG_VERSION, new VersionMessage(params));
// When connecting, the remote peer sends us a version message with various bits of
// useful data in it. We need to know the peer protocol version before we can talk to it.
versionMessage = (VersionMessage) readMessage();
// Now it's our turn ...
writeMessage(MSG_VERSION, new VersionMessage(params));
// Send an ACK message stating we accept the peers protocol version.
writeMessage(MSG_VERACK, new byte[] {});
// And get one back ...