1
0
mirror of https://github.com/bitcoin/bips.git synced 2024-11-19 09:50:06 +01:00

BIP155: change "time" to fixed 32 bit unsigned

32 bit unsigned can represent time up to year 2106
(32 bit signed is limited to just 2038).

So, we don't need to have "time" encoded as variable integer which would
take 5 bytes instead of 4.
This commit is contained in:
Vasil Dimov 2020-08-13 11:30:55 +02:00
parent cb071df902
commit 2c7630ec61
No known key found for this signature in database
GPG Key ID: 54DF06F64B55CBBF

View File

@ -46,7 +46,7 @@ The <code>addrv2</code> message is defined as a message where <code>pchCommand =
It is serialized in the standard encoding for P2P messages. It is serialized in the standard encoding for P2P messages.
Its format is similar to the current <code>addr</code> message format Its format is similar to the current <code>addr</code> message format
<ref>[https://bitcoin.org/en/developer-reference#addr Bitcoin Developer Reference: addr message]</ref>, with the difference that the <ref>[https://bitcoin.org/en/developer-reference#addr Bitcoin Developer Reference: addr message]</ref>, with the difference that the
fixed 16-byte IP address is replaced by a network ID and a variable-length address, and the time and services format has been changed to VARINT. fixed 16-byte IP address is replaced by a network ID and a variable-length address, and the services format has been changed to VARINT.
This means that the message contains a serialized <code>std::vector</code> of the following structure: This means that the message contains a serialized <code>std::vector</code> of the following structure:
@ -55,9 +55,9 @@ This means that the message contains a serialized <code>std::vector</code> of th
!Name !Name
!Description !Description
|- |-
| <code>VARINT</code> (unsigned) | <code>uint32_t</code>
| <code>time</code> | <code>time</code>
| Time that this node was last seen as connected to the network. A time in Unix epoch time format, up to 64 bits wide. | Time that this node was last seen as connected to the network. A time in Unix epoch time format.
|- |-
| <code>VARINT</code> (unsigned) | <code>VARINT</code> (unsigned)
| <code>services</code> | <code>services</code>
@ -144,8 +144,6 @@ The reference implementation is available at (to be done)
- Jonas Schnelli: change <code>services</code> field to VARINT, to make the message more compact in the likely case instead of always using 8 bytes. - Jonas Schnelli: change <code>services</code> field to VARINT, to make the message more compact in the likely case instead of always using 8 bytes.
- Luke-Jr: change <code>time</code> field to VARINT, for post-2038 compatibility.
- Gregory Maxwell: various suggestions regarding extensibility - Gregory Maxwell: various suggestions regarding extensibility
==Appendix A: Tor v2 address encoding== ==Appendix A: Tor v2 address encoding==