10 #include "validation.h" 14 static std::multimap<std::string, CZMQAbstractPublishNotifier*> mapPublishNotifiers;
16 static const char *MSG_HASHBLOCK =
"hashblock";
17 static const char *MSG_HASHTX =
"hashtx";
18 static const char *MSG_RAWBLOCK =
"rawblock";
19 static const char *MSG_RAWTX =
"rawtx";
20 static const char *MSG_RAWASSETMSG =
"rawmessage";
23 static int zmq_send_multipart(
void *sock,
const void* data,
size_t size, ...)
32 int rc = zmq_msg_init_size(&msg, size);
35 zmqError(
"Unable to initialize ZMQ msg");
40 void *buf = zmq_msg_data(&msg);
43 data = va_arg(args,
const void*);
45 rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
59 size = va_arg(args,
size_t);
70 std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator i = mapPublishNotifiers.find(
address);
72 if (i==mapPublishNotifiers.end())
74 psocket = zmq_socket(pcontext, ZMQ_PUB);
90 mapPublishNotifiers.insert(std::make_pair(
address,
this));
98 mapPublishNotifiers.insert(std::make_pair(
address,
this));
108 int count = mapPublishNotifiers.count(
address);
111 typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
112 std::pair<iterator, iterator> iterpair = mapPublishNotifiers.equal_range(
address);
114 for (iterator it = iterpair.first; it != iterpair.second; ++it)
116 if (it->second==
this)
118 mapPublishNotifiers.erase(it);
127 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
139 unsigned char msgseq[
sizeof(uint32_t)];
141 int rc = zmq_send_multipart(
psocket, command, strlen(command), data, size, msgseq, (
size_t)
sizeof(uint32_t),
nullptr);
156 for (
unsigned int i = 0; i < 32; i++)
157 data[31 - i] = hash.
begin()[i];
166 for (
unsigned int i = 0; i < 32; i++)
167 data[31 - i] = hash.
begin()[i];
182 zmqError(
"Can't read block from disk");
198 return SendMessage(MSG_RAWTX, &(*ss.begin()), ss.size());
206 std::string str = zmqmessage.createJsonString();
207 return SendMessage(MSG_RAWASSETMSG, &(*str.begin()), str.size());
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyMessage(const CMessage &message) override
std::string ToString() const
uint32_t nSequence
upcounting per message sequence number
CCriticalSection cs_main
Global state.
Double ended buffer combining vector and stream-like interfaces.
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyBlock(const CBlockIndex *pindex) override
uint256 GetBlockHash() const
bool SendMessage(const char *command, const void *data, size_t size)
const uint256 & GetHash() const
bool NotifyBlock(const CBlockIndex *pindex) override
Parameters that influence chain consensus.
#define LogPrint(category,...)
const_iterator begin() const
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
int RPCSerializationFlags()
void * memcpy(void *a, const void *b, size_t c)
std::string GetHex() const
The basic transaction that is broadcasted on the network and contained in blocks. ...
const Consensus::Params & GetConsensus() const
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
void zmqError(const char *str)
bool Initialize(void *pcontext) override