Author

Topic: What is the maximum allowed P2P message size? (Read 197 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
It is a bit redundant, but I think the reasoning is that MAX_SIZE is a hard maximum while MAX_PROTOCOL_MESSAGE_LENGTH can change.

MAX_SIZE is effectively a consensus rule because of its use in ReadCompactSize. It is a limit on how large a compact size unsigned integer can be. However MAX_PROTOCOL_MESSAGE_LENGTH can and has changed. So this check is basically just in case MAX_PROTOCOL_MESSAGE_LENGTH is increased to be larger than MAX_SIZE. It isn't necessary, but it helps a bit with readability and it helps developers in case someone forgets the MAX_SIZE constraint.
legendary
Activity: 1042
Merit: 2805
Bitcoin and C♯ Enthusiast
The dev. doc.[1] keeps referring to MAX_SIZE in serialize.h file[2] which is 32 MiB when it comes to message sizes but this strange* comparison in net.cpp[3] seems to be rejecting anything above 4 MB[4].
Am I reading it correctly or am I missing something here?

* Strange because it is basically saying if size > 33,554,432 OR size > 4,000,000 and obviously the first check is redundant since both values are constant.

[1] https://developer.bitcoin.org/reference/p2p_networking.html
[2] https://github.com/bitcoin/bitcoin/blob/60abd463ac2eaa8bc1d616d8c07880dc53d97211/src/serialize.h#L23
[3] https://github.com/bitcoin/bitcoin/blob/9bc7751cadbd038faf8ac1d62cda23fcf00d4cc2/src/net.cpp#L660
[4] https://github.com/bitcoin/bitcoin/blob/9bc7751cadbd038faf8ac1d62cda23fcf00d4cc2/src/net.h#L56
Jump to: