Skip to content

Commit

Permalink
protocol.h: Make enums in GetDataMsg concrete values
Browse files Browse the repository at this point in the history
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).

(cherry picked from commit bitcoin/bitcoin@1df3111)
  • Loading branch information
laanwj authored and str4d committed Aug 13, 2021
1 parent 68453f5 commit 85a87aa
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,18 @@ class CAddress : public CService
unsigned int nTime;
};

/** getdata message types */
/** getdata / inv message types.
* These numbers are defined by the protocol. When adding a new value, be sure
* to mention it in the respective ZIP, as well as checking for collisions with
* BIPs we might want to backport.
*/
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_FILTERED_BLOCK = 3, //!< Defined in BIP37
};

/** inv message data */
Expand Down

0 comments on commit 85a87aa

Please sign in to comment.