Skip to content

Commit 1df3111

Browse files
committed
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).
1 parent 2c09a52 commit 1df3111

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/protocol.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,20 +312,24 @@ class CAddress : public CService
312312
unsigned int nTime;
313313
};
314314

315-
/** getdata message types */
315+
/** getdata message type flags */
316316
const uint32_t MSG_WITNESS_FLAG = 1 << 30;
317317
const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2;
318+
319+
/** getdata / inv message types.
320+
* These numbers are defined by the protocol. When adding a new value, be sure
321+
* to mention it in the respective BIP.
322+
*/
318323
enum GetDataMsg
319324
{
320325
UNDEFINED = 0,
321-
MSG_TX,
322-
MSG_BLOCK,
323-
MSG_TYPE_MAX = MSG_BLOCK,
326+
MSG_TX = 1,
327+
MSG_BLOCK = 2,
324328
// The following can only occur in getdata. Invs always use TX or BLOCK.
325-
MSG_FILTERED_BLOCK,
326-
MSG_CMPCT_BLOCK,
327-
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG,
328-
MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG,
329+
MSG_FILTERED_BLOCK = 3, //!< Defined in BIP37
330+
MSG_CMPCT_BLOCK = 4, //!< Defined in BIP152
331+
MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG, //!< Defined in BIP144
332+
MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG, //!< Defined in BIP144
329333
MSG_FILTERED_WITNESS_BLOCK = MSG_FILTERED_BLOCK | MSG_WITNESS_FLAG,
330334
};
331335

0 commit comments

Comments
 (0)