Add protocol messages for short-ids blocks

This commit is contained in:
Matt Corallo 2016-06-06 01:26:52 -07:00
parent e3b2222144
commit 00c40784fe
3 changed files with 44 additions and 5 deletions

View file

@ -35,6 +35,10 @@ const char *FILTERCLEAR="filterclear";
const char *REJECT="reject"; const char *REJECT="reject";
const char *SENDHEADERS="sendheaders"; const char *SENDHEADERS="sendheaders";
const char *FEEFILTER="feefilter"; const char *FEEFILTER="feefilter";
const char *SENDCMPCT="sendcmpct";
const char *CMPCTBLOCK="cmpctblock";
const char *GETBLOCKTXN="getblocktxn";
const char *BLOCKTXN="blocktxn";
}; };
static const char* ppszTypeName[] = static const char* ppszTypeName[] =
@ -42,7 +46,8 @@ static const char* ppszTypeName[] =
"ERROR", // Should never occur "ERROR", // Should never occur
NetMsgType::TX, NetMsgType::TX,
NetMsgType::BLOCK, NetMsgType::BLOCK,
"filtered block" // Should never occur "filtered block", // Should never occur
"compact block" // Should never occur
}; };
/** All known message types. Keep this in the same order as the list of /** All known message types. Keep this in the same order as the list of
@ -70,7 +75,11 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::FILTERCLEAR, NetMsgType::FILTERCLEAR,
NetMsgType::REJECT, NetMsgType::REJECT,
NetMsgType::SENDHEADERS, NetMsgType::SENDHEADERS,
NetMsgType::FEEFILTER NetMsgType::FEEFILTER,
NetMsgType::SENDCMPCT,
NetMsgType::CMPCTBLOCK,
NetMsgType::GETBLOCKTXN,
NetMsgType::BLOCKTXN,
}; };
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes)); const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));

View file

@ -217,6 +217,32 @@ extern const char *SENDHEADERS;
* @since protocol version 70013 as described by BIP133 * @since protocol version 70013 as described by BIP133
*/ */
extern const char *FEEFILTER; extern const char *FEEFILTER;
/**
* Contains a 1-byte bool and 8-byte LE version number.
* Indicates that a node is willing to provide blocks via "cmpctblock" messages.
* May indicate that a node prefers to receive new block announcements via a
* "cmpctblock" message rather than an "inv", depending on message contents.
* @since protocol version 70014 as described by BIP 152
*/
extern const char *SENDCMPCT;
/**
* Contains a CBlockHeaderAndShortTxIDs object - providing a header and
* list of "short txids".
* @since protocol version 70014 as described by BIP 152
*/
extern const char *CMPCTBLOCK;
/**
* Contains a BlockTransactionsRequest
* Peer should respond with "blocktxn" message.
* @since protocol version 70014 as described by BIP 152
*/
extern const char *GETBLOCKTXN;
/**
* Contains a BlockTransactions.
* Sent in response to a "getblocktxn" message.
* @since protocol version 70014 as described by BIP 152
*/
extern const char *BLOCKTXN;
}; };
/* Get a vector of all valid message types (see above) */ /* Get a vector of all valid message types (see above) */
@ -315,9 +341,10 @@ public:
enum { enum {
MSG_TX = 1, MSG_TX = 1,
MSG_BLOCK, MSG_BLOCK,
// Nodes may always request a MSG_FILTERED_BLOCK in a getdata, however, // Nodes may always request a MSG_FILTERED_BLOCK/MSG_CMPCT_BLOCK in a getdata, however,
// MSG_FILTERED_BLOCK should not appear in any invs except as a part of getdata. // MSG_FILTERED_BLOCK/MSG_CMPCT_BLOCK should not appear in any invs except as a part of getdata.
MSG_FILTERED_BLOCK, MSG_FILTERED_BLOCK,
MSG_CMPCT_BLOCK,
}; };
#endif // BITCOIN_PROTOCOL_H #endif // BITCOIN_PROTOCOL_H

View file

@ -9,7 +9,7 @@
* network protocol versioning * network protocol versioning
*/ */
static const int PROTOCOL_VERSION = 70013; static const int PROTOCOL_VERSION = 70014;
//! initial proto version, to be increased after version/verack negotiation //! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209; static const int INIT_PROTO_VERSION = 209;
@ -39,4 +39,7 @@ static const int SENDHEADERS_VERSION = 70012;
//! "feefilter" tells peers to filter invs to you by fee starts with this version //! "feefilter" tells peers to filter invs to you by fee starts with this version
static const int FEEFILTER_VERSION = 70013; static const int FEEFILTER_VERSION = 70013;
//! shord-id-based block download starts with this version
static const int SHORT_IDS_BLOCKS_VERSION = 70014;
#endif // BITCOIN_VERSION_H #endif // BITCOIN_VERSION_H