Title: Variable length integer - what the hell? Post by: piotr_n on July 29, 2011, 06:26:25 PM Variable length integer, from the bitcoin protocol.
It states very clearly in the wiki (https://en.bitcoin.it/wiki/Protocol_Specification#Variable_length_integer): Quote <= 0xffff 3 0xfd + uint16_t Here it makes sense.But the problem is, when I do getblocks (https://en.bitcoin.it/wiki/Protocol_Specification#getblocks) with hash_stop set to zero, I get back inv (https://en.bitcoin.it/wiki/Protocol_Specification#inv) where the count field is "fd f4 01" Now, if I parse it according to the spec, it give me value 753 (0xfd + 0x01f4). While in fact the proper value is 500 (0x01f4) So which one is wrong; the spec or the value inside the message? Or am I wrong somewhere? Title: Re: Variable length integer - what the hell? Post by: realnowhereman on July 29, 2011, 06:37:14 PM You're wrong I'm afraid.
The way the variable length integer works is:
Title: Re: Variable length integer - what the hell? Post by: kokjo on July 29, 2011, 07:41:53 PM i hope you do read python:
Code: if ord(bdata[0]) <= 0xfc: Title: Re: Variable length integer - what the hell? Post by: error on July 29, 2011, 08:18:08 PM You missed the fact that Bitcoin uses little endian on the network. This is probably Bitcoin's biggest design mistake.
Title: Re: Variable length integer - what the hell? Post by: JoelKatz on July 29, 2011, 08:27:54 PM You missed the fact that Bitcoin uses little endian on the network. This is probably Bitcoin's biggest design mistake. Here we see a master of the "praise with faint damn" technique. I bow to you, sir.Title: Re: Variable length integer - what the hell? Post by: 2112 on July 29, 2011, 09:49:52 PM You missed the fact that Bitcoin uses little endian on the network. This is probably Bitcoin's biggest design mistake. I wouldn't call it biggest, but probably one of the most difficult to rectify. The longer it stays this way the higher are the chances that people enshrine this mistake in the alternative clients. At present time the alternative block layout should be not too hard to implement. So long as it stays this way all the implementations will suffer problems related to those inconsistencies, e.g. ufsminer which was mining on the incorrect endianness. |