Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: TT on November 13, 2011, 05:12:06 AM



Title: Node not responding to getdata message
Post by: TT on November 13, 2011, 05:12:06 AM
I'm working on the network i/o for a bitcoin node. Immediately after receiving an inv message from a peer,
I'm sending it back but just changing the "inv" command to "getdata". It is my understanding that the inventory
list structure is identical in both types of message, and therefore the payload can be identical. Only the 12 byte
command code needs to be changed from {'i','n','v',0,0,0,0,0,0,0,0,0} to {'g','e','t','d','a','t','a',0,0,0,0,0}. Other
nodes seem to recognize the message as a getdata message, but are not replying with any tx or block messages.

Any ideas why?


Title: Re: Node not responding to getdata message
Post by: theymos on November 13, 2011, 05:22:52 AM
Are you updating the checksum?


Title: Re: Node not responding to getdata message
Post by: TT on November 13, 2011, 05:27:00 AM
If the payload is the same, wouldn't the checksum also remain the same?


Title: Re: Node not responding to getdata message
Post by: theymos on November 13, 2011, 06:16:22 AM
Ah, you're right about that.

Post a hexdump of what you're sending.


Title: Re: Node not responding to getdata message
Post by: TT on November 13, 2011, 06:55:32 AM
OK, I received the following data:
----
Received data: 0xf9 0xbe 0xb4 0xd9 0x69 0x6e 0x76 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x25 0x00 0x00 0x00 0x8f 0xa1 0x8b 0x5e 0x01 0x01 0x00 0x00 0x00 0x79 0xb8 0x25 0x10 0x3d 0xca 0x85 0xf8 0x90 0xc2 0x24 0x79 0x22 0x1c 0x27 0xab 0x4f 0x73 0x60 0x49 0x94 0x54 0x3a 0xe8 0x3e 0x4a 0x4e 0x10 0x43 0x51 0x2b 0x8c
----
Formatted in human-readable form, it's:

Command: inv
Payload size(bytes): 37
Inventory count: 1
  Item 1:
    Type: MSG_TX
    Hash: 8c2b5143104e4a3ee83a54944960734fab271c227924c290f885ca3d1025b879

I'm sending back:
----
Sending getdata: 0xf9 0xbe 0xb4 0xd9 0x67 0x65 0x74 0x64 0x61 0x74 0x61 0x00 0x00 0x00 0x00 0x00 0x25 0x00 0x00 0x00 0x8f 0xa1 0x8b 0x5e 0x01 0x01 0x00 0x00 0x00 0x79 0xb8 0x25 0x10 0x3d 0xca 0x85 0xf8 0x90 0xc2 0x24 0x79 0x22 0x1c 0x27 0xab 0x4f 0x73 0x60 0x49 0x94 0x54 0x3a 0xe8 0x3e 0x4a 0x4e 0x10 0x43 0x51 0x2b 0x8c
----


Title: Re: Node not responding to getdata message
Post by: TT on November 13, 2011, 01:22:03 PM
I just dropped the four checksum bytes and it worked!

I think this detail was omitted in https://en.bitcoin.it/wiki/Protocol_specification

It says
Quote
The version and verack messages do not have a checksum, the payload starts 4 bytes earlier.

Apparently, this is also the case for getdata messages. Someone might want to update the wiki.

-TT


Title: Re: Node not responding to getdata message
Post by: theymos on November 14, 2011, 10:29:12 AM
Hmm... I'm pretty sure my network code puts a checksum on those messages.


Title: Re: Node not responding to getdata message
Post by: kokjo on November 14, 2011, 10:38:23 AM
Hmm... I'm pretty sure my network code puts a checksum on those messages.
mine too and they are working. putting checksums on anything, but version and verack