From 1df311118d79c04df1d41e044b19444cfda015da Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 4 Oct 2016 17:55:12 +0200 Subject: protocol.h: Make enums in GetDataMsg concrete values This concretizes the numbers and adds a comment to make it clear that these numbers are fixed by the protocol, and may avoid people forgetting to claim numbers in the future (e.g. issue #8500). Also gets rid of a weird unused `MSG_TYPE_MAX` in the middle of the enumeration (thanks @paveljanik for noticing). --- src/protocol.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/protocol.h') diff --git a/src/protocol.h b/src/protocol.h index cdb76b9038..d19e0d3a5e 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -312,20 +312,24 @@ public: unsigned int nTime; }; -/** getdata message types */ +/** getdata message type flags */ const uint32_t MSG_WITNESS_FLAG = 1 << 30; const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2; + +/** getdata / inv message types. + * These numbers are defined by the protocol. When adding a new value, be sure + * to mention it in the respective BIP. + */ enum GetDataMsg { UNDEFINED = 0, - MSG_TX, - MSG_BLOCK, - MSG_TYPE_MAX = MSG_BLOCK, + MSG_TX = 1, + MSG_BLOCK = 2, // The following can only occur in getdata. Invs always use TX or BLOCK. - MSG_FILTERED_BLOCK, - MSG_CMPCT_BLOCK, - MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, - MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG, + MSG_FILTERED_BLOCK = 3, //!< Defined in BIP37 + MSG_CMPCT_BLOCK = 4, //!< Defined in BIP152 + MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, //!< Defined in BIP144 + MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG, //!< Defined in BIP144 MSG_FILTERED_WITNESS_BLOCK = MSG_FILTERED_BLOCK | MSG_WITNESS_FLAG, }; -- cgit v1.2.3