10 #include "validation.h"
12 static std::multimap<std::string, CZMQAbstractPublishNotifier*> mapPublishNotifiers;
14 static const char *MSG_HASHBLOCK =
"hashblock";
15 static const char *MSG_HASHTX =
"hashtx";
16 static const char *MSG_RAWBLOCK =
"rawblock";
17 static const char *MSG_RAWTX =
"rawtx";
20 static int zmq_send_multipart(
void *sock,
const void* data,
size_t size, ...)
29 int rc = zmq_msg_init_size(&msg, size);
32 zmqError(
"Unable to initialize ZMQ msg");
37 void *buf = zmq_msg_data(&msg);
40 data = va_arg(args,
const void*);
42 rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
56 size = va_arg(args,
size_t);
67 std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator i = mapPublishNotifiers.find(
address);
69 if (i==mapPublishNotifiers.end())
71 psocket = zmq_socket(pcontext, ZMQ_PUB);
87 mapPublishNotifiers.emplace(
address,
this);
95 mapPublishNotifiers.emplace(
address,
this);
105 int count = mapPublishNotifiers.count(
address);
108 typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
109 std::pair<iterator, iterator> iterpair = mapPublishNotifiers.equal_range(
address);
111 for (iterator it = iterpair.first; it != iterpair.second; ++it)
113 if (it->second==
this)
115 mapPublishNotifiers.erase(it);
124 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
136 unsigned char msgseq[
sizeof(uint32_t)];
138 int rc = zmq_send_multipart(
psocket, command, strlen(command), data, size, msgseq, (
size_t)
sizeof(uint32_t), (
void*)0);
153 for (
unsigned int i = 0; i < 32; i++)
154 data[31 - i] = hash.
begin()[i];
163 for (
unsigned int i = 0; i < 32; i++)
164 data[31 - i] = hash.
begin()[i];
178 zmqError(
"Can't read block from disk");
const_iterator begin() const
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetBlockHash() const
The basic transaction that is broadcasted on the network and contained in blocks.
const uint256 & GetHash() const
bool SendMessage(const char *command, const void *data, size_t size)
bool Initialize(void *pcontext)
bool NotifyBlock(const CBlockIndex *pindex)
bool NotifyTransaction(const CTransaction &transaction)
bool NotifyBlock(const CBlockIndex *pindex)
bool NotifyTransaction(const CTransaction &transaction)
std::string GetHex() const
void * memcpy(void *a, const void *b, size_t c)
#define LogPrint(category,...)
RecursiveMutex cs_main
Global state.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos)
void zmqError(const char *str)