aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-10-04 17:55:12 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-10-05 13:32:20 +0200
commit1df311118d79c04df1d41e044b19444cfda015da (patch)
tree1c9c03183975fc78c8d59afdb5eac3c5613ab6b7
parent2c09a5209ab00573a2422e1e65c437a6e2f59624 (diff)
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).
-rw-r--r--src/protocol.h20
1 files changed, 12 insertions, 8 deletions
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,
};