Skip to content

Commit 6c04b50

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23471: doc: Improve ZMQ documentation
9544ab6 doc: Improve ZMQ documentation (node01) Pull request description: This PR intends to clarify: . when ZMQ notifications occur . the message structure of each topic Closes bitcoin/bitcoin#23452 (comment) ACKs for top commit: theStack: ACK 9544ab6 Tree-SHA512: 3b1314ad5eb8c359ffabd91ce9b47cf6cf8efa69be083a3bb5d865833ac67d7a88a8e012c4a4f59f2cd2a0e7f491e828897e85e9d01bae72ee83c4a6ad459f6e
2 parents 87ce2d6 + 9544ab6 commit 6c04b50

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

doc/zmq.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ For instance:
9191
Each PUB notification has a topic and body, where the header
9292
corresponds to the notification type. For instance, for the
9393
notification `-zmqpubhashtx` the topic is `hashtx` (no null
94-
terminator) and the body is the transaction hash (32
95-
bytes) for all but `sequence` topic. For `sequence`, the body
96-
is structured as the following based on the type of message:
94+
terminator). These options can also be provided in bitcoin.conf.
95+
96+
The topics are:
97+
98+
`sequence`: the body is structured as the following based on the type of message:
9799

98100
<32-byte hash>C : Blockhash connected
99101
<32-byte hash>D : Blockhash disconnected
@@ -102,7 +104,24 @@ is structured as the following based on the type of message:
102104

103105
Where the 8-byte uints correspond to the mempool sequence number.
104106

105-
These options can also be provided in bitcoin.conf.
107+
`rawtx`: Notifies about all transactions, both when they are added to mempool or when a new block arrives. This means a transaction could be published multiple times. First, when it enters the mempool and then again in each block that includes it. The messages are ZMQ multipart messages with three parts. The first part is the topic (`rawtx`), the second part is the serialized transaction, and the last part is a sequence number (representing the message count to detect lost messages).
108+
109+
| rawtx | <serialized transaction> | <uint32 sequence number in Little Endian>
110+
111+
`hashtx`: Notifies about all transactions, both when they are added to mempool or when a new block arrives. This means a transaction could be published multiple times. First, when it enters the mempool and then again in each block that includes it. The messages are ZMQ multipart messages with three parts. The first part is the topic (`hashtx`), the second part is the 32-byte transaction hash, and the last part is a sequence number (representing the message count to detect lost messages).
112+
113+
| hashtx | <32-byte transaction hash in Little Endian> | <uint32 sequence number in Little Endian>
114+
115+
116+
`rawblock`: Notifies when the chain tip is updated. Messages are ZMQ multipart messages with three parts. The first part is the topic (`rawblock`), the second part is the serialized block, and the last part is a sequence number (representing the message count to detect lost messages).
117+
118+
| rawblock | <serialized block> | <uint32 sequence number in Little Endian>
119+
120+
`hashblock`: Notifies when the chain tip is updated. Messages are ZMQ multipart messages with three parts. The first part is the topic (`hashblock`), the second part is the 32-byte block hash, and the last part is a sequence number (representing the message count to detect lost messages).
121+
122+
| hashblock | <32-byte block hash in Little Endian> | <uint32 sequence number in Little Endian>
123+
124+
**_NOTE:_** Note that the 32-byte hashes are in Little Endian and not in the Big Endian format that the RPC interface and block explorers use to display transaction and block hashes.
106125

107126
ZeroMQ endpoint specifiers for TCP (and others) are documented in the
108127
[ZeroMQ API](http://api.zeromq.org/4-0:_start).

0 commit comments

Comments
 (0)