Bitmessage / PyBitmessage

Reference client for Bitmessage: a P2P encrypted decentralised communication protocol:
https://bitmessage.org/wiki/Main_Page
Other
2.81k stars 575 forks source link

Bit numbering scheme in pubkey/service features #769

Open Kagami opened 9 years ago

Kagami commented 9 years ago

Hi. Another spec quirk.

Service features bitfield uses LSB 0: https://github.com/Bitmessage/PyBitmessage/blob/master/src/shared.py#L149 https://bitmessage.org/wiki/Protocol_specification#version

At the same time pubkey behavior bitfield uses MSB 0: https://github.com/Bitmessage/PyBitmessage/blob/master/src/class_singleWorker.py#L272 https://bitmessage.org/wiki/Protocol_specification#Pubkey_bitfield_features https://github.com/Bitmessage/PyBitmessage/blob/master/src/class_singleWorker.py#L747 https://github.com/Bitmessage/PyBitmessage/blob/master/src/shared.py#L469

Should we be more consistent or at least mention this contradiction in the wiki?

Atheros1 commented 9 years ago
>>> from struct import *
>>> pack('>q',1)
'\x00\x00\x00\x00\x00\x00\x00\x01'

It appears to me that shared.py#L149 is MSB 0.

Kagami commented 9 years ago

Hm, you are right. I misread value 1 in

Value Name Description 1 NODE_NETWORK This is a normal network node.

as a bit number. But it's still not very clear because pubkey bitfield uses bits and services bitfield uses BE values.

Atheros1 commented 9 years ago

You are right that that is strange. The services bitfield I copied from Bitcoin because it seemed like a good idea but we don't make use of it yet and it appears that neither does Bitcoin.

Kagami commented 9 years ago

I know one very good use case for services bitfield: it will allow to find WebSocket gateway nodes for web clients because they can't create normal TCP connections. (Similar idea was proposed here.) Also you was proposed to take one bit for TLS-enabled nodes.