forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1
BIP155: CompactSize vs VARINT
Vasil Dimov edited this page Aug 11, 2020
·
1 revision
Currently BIP155 specifies to use VARINT
for time
and services
. The source code in pull/19031 also uses VARINT
.
CompactSize
is used in the P2P protocol and is documented here: https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer
- Currently stored in 4 bytes, but would require more after 2038 (if interpreted as signed 4 byte integer; if interpreted as unsigned then 4 bytes are enough until year 2106)
- VARINT would change it to 5 bytes today and remain 5 bytes after 2038 (unsigned)
-
CompactSize
would change it to 5 bytes today and remain 5 bytes after 2038 (unsigned)
- Currently stored in 8 bytes, but only holding numbers up to 1039
- VARINT would change it to
- con: would introduce a new "compressed" integer encoding in the P2P layer
- pro:
CompactSize
is already used in the P2P protocol and is documented.