Skip to content

Commit 00c4078

Browse files
committed
Add protocol messages for short-ids blocks
1 parent e3b2222 commit 00c4078

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

src/protocol.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ const char *FILTERCLEAR="filterclear";
3535
const char *REJECT="reject";
3636
const char *SENDHEADERS="sendheaders";
3737
const char *FEEFILTER="feefilter";
38+
const char *SENDCMPCT="sendcmpct";
39+
const char *CMPCTBLOCK="cmpctblock";
40+
const char *GETBLOCKTXN="getblocktxn";
41+
const char *BLOCKTXN="blocktxn";
3842
};
3943

4044
static const char* ppszTypeName[] =
4145
{
4246
"ERROR", // Should never occur
4347
NetMsgType::TX,
4448
NetMsgType::BLOCK,
45-
"filtered block" // Should never occur
49+
"filtered block", // Should never occur
50+
"compact block" // Should never occur
4651
};
4752

4853
/** All known message types. Keep this in the same order as the list of
@@ -70,7 +75,11 @@ const static std::string allNetMessageTypes[] = {
7075
NetMsgType::FILTERCLEAR,
7176
NetMsgType::REJECT,
7277
NetMsgType::SENDHEADERS,
73-
NetMsgType::FEEFILTER
78+
NetMsgType::FEEFILTER,
79+
NetMsgType::SENDCMPCT,
80+
NetMsgType::CMPCTBLOCK,
81+
NetMsgType::GETBLOCKTXN,
82+
NetMsgType::BLOCKTXN,
7483
};
7584
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));
7685

src/protocol.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,32 @@ extern const char *SENDHEADERS;
217217
* @since protocol version 70013 as described by BIP133
218218
*/
219219
extern const char *FEEFILTER;
220+
/**
221+
* Contains a 1-byte bool and 8-byte LE version number.
222+
* Indicates that a node is willing to provide blocks via "cmpctblock" messages.
223+
* May indicate that a node prefers to receive new block announcements via a
224+
* "cmpctblock" message rather than an "inv", depending on message contents.
225+
* @since protocol version 70014 as described by BIP 152
226+
*/
227+
extern const char *SENDCMPCT;
228+
/**
229+
* Contains a CBlockHeaderAndShortTxIDs object - providing a header and
230+
* list of "short txids".
231+
* @since protocol version 70014 as described by BIP 152
232+
*/
233+
extern const char *CMPCTBLOCK;
234+
/**
235+
* Contains a BlockTransactionsRequest
236+
* Peer should respond with "blocktxn" message.
237+
* @since protocol version 70014 as described by BIP 152
238+
*/
239+
extern const char *GETBLOCKTXN;
240+
/**
241+
* Contains a BlockTransactions.
242+
* Sent in response to a "getblocktxn" message.
243+
* @since protocol version 70014 as described by BIP 152
244+
*/
245+
extern const char *BLOCKTXN;
220246
};
221247

222248
/* Get a vector of all valid message types (see above) */
@@ -315,9 +341,10 @@ class CInv
315341
enum {
316342
MSG_TX = 1,
317343
MSG_BLOCK,
318-
// Nodes may always request a MSG_FILTERED_BLOCK in a getdata, however,
319-
// MSG_FILTERED_BLOCK should not appear in any invs except as a part of getdata.
344+
// Nodes may always request a MSG_FILTERED_BLOCK/MSG_CMPCT_BLOCK in a getdata, however,
345+
// MSG_FILTERED_BLOCK/MSG_CMPCT_BLOCK should not appear in any invs except as a part of getdata.
320346
MSG_FILTERED_BLOCK,
347+
MSG_CMPCT_BLOCK,
321348
};
322349

323350
#endif // BITCOIN_PROTOCOL_H

src/version.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* network protocol versioning
1010
*/
1111

12-
static const int PROTOCOL_VERSION = 70013;
12+
static const int PROTOCOL_VERSION = 70014;
1313

1414
//! initial proto version, to be increased after version/verack negotiation
1515
static const int INIT_PROTO_VERSION = 209;
@@ -39,4 +39,7 @@ static const int SENDHEADERS_VERSION = 70012;
3939
//! "feefilter" tells peers to filter invs to you by fee starts with this version
4040
static const int FEEFILTER_VERSION = 70013;
4141

42+
//! shord-id-based block download starts with this version
43+
static const int SHORT_IDS_BLOCKS_VERSION = 70014;
44+
4245
#endif // BITCOIN_VERSION_H

0 commit comments

Comments
 (0)