4

If I want to send transaction indexes in either cmpctblock or getblocktxn messages, they are represented as differences. For example if I want to send indexes 0, 54, 65, 67 and 1236, they are represented as 0, 53, 10, 1 and 1168.

Why was this done this way? Why not only indexes are passed, but their differences? Is this due to some optimization or something else?

1 Answer 1

4

Numbers up to 252 are encoded as a single byte, while larger numbers take 3 bytes. Differential encoding is effectively a form of compression, reducing the size of the data without losing information (the same set of transactions is communicated). Size of encoding matters in compact blocks, as its purpose is reducing latency. One aspect of that is aiming to fit everything in as few IP packets as possible (typically around 1500 bytes on the internet).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.