9 #include <validation.h> 13 static std::multimap<std::string, CZMQAbstractPublishNotifier*> mapPublishNotifiers;
15 static const char *MSG_HASHBLOCK =
"hashblock";
16 static const char *MSG_HASHTX =
"hashtx";
17 static const char *MSG_RAWBLOCK =
"rawblock";
18 static const char *MSG_RAWTX =
"rawtx";
21 static int zmq_send_multipart(
void *sock,
const void*
data,
size_t size, ...)
30 int rc = zmq_msg_init_size(&msg, size);
33 zmqError(
"Unable to initialize ZMQ msg");
38 void *buf = zmq_msg_data(&msg);
41 data = va_arg(args,
const void*);
43 rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
57 size = va_arg(args,
size_t);
68 std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator i = mapPublishNotifiers.find(
address);
70 if (i==mapPublishNotifiers.end())
72 psocket = zmq_socket(pcontext, ZMQ_PUB);
88 mapPublishNotifiers.insert(std::make_pair(
address,
this));
96 mapPublishNotifiers.insert(std::make_pair(
address,
this));
109 typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
110 std::pair<iterator, iterator> iterpair = mapPublishNotifiers.equal_range(
address);
112 for (iterator it = iterpair.first; it != iterpair.second; ++it)
114 if (it->second==
this)
116 mapPublishNotifiers.erase(it);
125 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
137 unsigned char msgseq[
sizeof(uint32_t)];
139 int rc = zmq_send_multipart(
psocket, command, strlen(command), data, size, msgseq, (
size_t)
sizeof(uint32_t),
nullptr);
154 for (
unsigned int i = 0; i < 32; i++)
155 data[31 - i] = hash.
begin()[i];
164 for (
unsigned int i = 0; i < 32; i++)
165 data[31 - i] = hash.
begin()[i];
180 zmqError(
"Can't read block from disk");
196 return SendMessage(MSG_RAWTX, &(*ss.begin()), ss.size());
bool NotifyTransaction(const CTransaction &transaction) override
uint32_t nSequence
upcounting per message sequence number
const_iterator begin() const
std::string GetHex() const
const Consensus::Params & GetConsensus() const
assert(len-trim+(2 *lenIndices)<=WIDTH)
Double ended buffer combining vector and stream-like interfaces.
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyBlock(const CBlockIndex *pindex) override
bool ReadBlockFromDisk(Block &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
bool SendMessage(const char *command, const void *data, size_t size)
bool NotifyBlock(const CBlockIndex *pindex) override
Parameters that influence chain consensus.
#define LogPrint(category,...)
uint8_t const size_t const size
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)
const uint256 & GetHash() const
The basic transaction that is broadcasted on the network and contained in blocks. ...
void zmqError(const char *str)
uint256 GetBlockHash() const
bool Initialize(void *pcontext) override