8#include <chainparams.h>
27static std::multimap<std::string, CZMQAbstractPublishNotifier *>
44 int rc = zmq_msg_init_size(&msg, size);
46 zmqError(
"Unable to initialize ZMQ msg");
51 void *buf = zmq_msg_data(&msg);
52 memcpy(buf, data, size);
54 data = va_arg(args,
const void *);
56 rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
70 size = va_arg(args,
size_t);
80 std::multimap<std::string, CZMQAbstractPublishNotifier *>::iterator i =
84 psocket = zmq_socket(pcontext, ZMQ_PUB);
91 "zmq: Outbound message high water mark for %s at %s is %d\n",
94 int rc = zmq_setsockopt(
psocket, ZMQ_SNDHWM,
98 zmqError(
"Failed to set outbound message high water mark");
103 const int so_keepalive_option{1};
104 rc = zmq_setsockopt(
psocket, ZMQ_TCP_KEEPALIVE, &so_keepalive_option,
105 sizeof(so_keepalive_option));
107 zmqError(
"Failed to set SO_KEEPALIVE");
126 "zmq: Outbound message high water mark for %s at %s is %d\n",
145 typedef std::multimap<std::string, CZMQAbstractPublishNotifier *>::iterator
147 std::pair<iterator, iterator> iterpair =
150 for (iterator it = iterpair.first; it != iterpair.second; ++it) {
151 if (it->second ==
this) {
160 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
173 uint8_t msgseq[
sizeof(uint32_t)];
176 msgseq, (
size_t)
sizeof(uint32_t),
nullptr);
192 for (
unsigned int i = 0; i < 32; i++) {
193 data[31 - i] = hash.
begin()[i];
199 const CTransaction &transaction) {
200 TxId txid = transaction.GetId();
204 for (
unsigned int i = 0; i < 32; i++) {
205 data[31 - i] = txid.
begin()[i];
217 zmqError(
"Can't read block from disk");
227 const CTransaction &transaction) {
228 TxId txid = transaction.GetId();
241 hash.
GetHex(), this->address);
243 for (
unsigned int i = 0; i <
sizeof(
BlockHash); i++) {
247 data[
sizeof(data) - 1] =
'C';
255 hash.
GetHex(), this->address);
257 for (
unsigned int i = 0; i <
sizeof(
BlockHash); i++) {
261 data[
sizeof(data) - 1] =
'D';
266 const CTransaction &transaction, uint64_t mempool_sequence) {
267 TxId txid = transaction.GetId();
269 txid.
GetHex(), this->address);
270 uint8_t data[
sizeof(
TxId) +
sizeof(mempool_sequence) + 1];
271 for (
unsigned int i = 0; i <
sizeof(
TxId); i++) {
272 data[
sizeof(
TxId) - 1 - i] = txid.
begin()[i];
275 data[
sizeof(
TxId)] =
'A';
281 const CTransaction &transaction, uint64_t mempool_sequence) {
282 TxId txid = transaction.GetId();
284 txid.
GetHex(), this->address);
285 uint8_t data[
sizeof(
TxId) +
sizeof(mempool_sequence) + 1];
286 for (
unsigned int i = 0; i <
sizeof(
TxId); i++) {
287 data[
sizeof(
TxId) - 1 - i] = txid.
begin()[i];
290 data[
sizeof(
TxId)] =
'R';
The block chain is a tree shaped structure starting with the genesis block at the root,...
BlockHash GetBlockHash() const
Double ended buffer combining vector and stream-like interfaces.
const_iterator begin() const
int outbound_message_high_water_mark
bool SendZmqMessage(const char *command, const void *data, size_t size)
uint32_t nSequence
upcounting per message sequence number
bool Initialize(void *pcontext) override
bool NotifyBlock(const CBlockIndex *pindex) override
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyBlock(const CBlockIndex *pindex) override
const std::function< bool(CBlock &, const CBlockIndex &)> m_get_block_by_index
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence) override
bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence) override
bool NotifyBlockConnect(const CBlockIndex *pindex) override
bool NotifyBlockDisconnect(const CBlockIndex *pindex) override
std::string GetHex() const
static void WriteLE32(uint8_t *ptr, uint32_t x)
static void WriteLE64(uint8_t *ptr, uint64_t x)
#define LogPrint(category,...)
int RPCSerializationFlags()
Retrieves any serialization flags requested in command line argument.
A BlockHash is a unqiue identifier for a block.
A TxId is the identifier of a transaction.
static const int PROTOCOL_VERSION
network protocol versioning
static const char * MSG_HASHBLOCK
static const char * MSG_SEQUENCE
static std::multimap< std::string, CZMQAbstractPublishNotifier * > mapPublishNotifiers
static const char * MSG_RAWBLOCK
static const char * MSG_RAWTX
static int zmq_send_multipart(void *sock, const void *data, size_t size,...)
static const char * MSG_HASHTX
void zmqError(const char *str)