62 int rc = zmq_msg_init_size(&msg, size);
65 zmqError(
"Unable to initialize ZMQ msg");
70 void *buf = zmq_msg_data(&msg);
71 memcpy(buf, data, size);
73 data = va_arg(
args,
const void*);
75 rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
89 size = va_arg(
args,
size_t);
97 const std::string tcp_prefix =
"tcp://";
98 const size_t tcp_index = zmq_address.rfind(tcp_prefix);
99 const size_t colon_index = zmq_address.rfind(
":");
100 if (tcp_index == 0 && colon_index != std::string::npos) {
101 const std::string
ip = zmq_address.substr(tcp_prefix.length(), colon_index - tcp_prefix.length());
104 if (addr.
IsIPv6())
return true;
118 psocket = zmq_socket(pcontext, ZMQ_PUB);
121 zmqError(
"Failed to create socket");
130 zmqError(
"Failed to set outbound message high water mark");
135 const int so_keepalive_option {1};
136 rc = zmq_setsockopt(
psocket, ZMQ_TCP_KEEPALIVE, &so_keepalive_option,
sizeof(so_keepalive_option));
138 zmqError(
"Failed to set SO_KEEPALIVE");
145 rc = zmq_setsockopt(
psocket, ZMQ_IPV6, &enable_ipv6,
sizeof(enable_ipv6));
184 typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
187 for (iterator it = iterpair.first; it != iterpair.second; ++it)
189 if (it->second==
this)
200 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
212 unsigned char msgseq[
sizeof(uint32_t)];
229 for (
unsigned int i = 0; i < 32; i++) {
230 data[31 - i] = hash.
begin()[i];
240 for (
unsigned int i = 0; i < 32; i++) {
241 data[31 - i] = hash.
begin()[i];
254 zmqError(
"Can't read block from disk");
276 unsigned char data[
sizeof(hash) +
sizeof(label) +
sizeof(uint64_t)];
277 for (
unsigned int i = 0; i <
sizeof(hash); ++i) {
278 data[
sizeof(hash) - 1 - i] = hash.
begin()[i];
280 data[
sizeof(hash)] = label;
281 if (sequence)
WriteLE64(data +
sizeof(hash) +
sizeof(label), *sequence);
const CChainParams & Params()
Return the currently selected parameters.
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetBlockHash() const
const Consensus::Params & GetConsensus() const
The basic transaction that is broadcasted on the network and contained in blocks.
const uint256 & GetHash() 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
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
const_iterator begin() const
std::string GetHex() const
static void WriteLE32(unsigned char *ptr, uint32_t x)
static void WriteLE64(unsigned char *ptr, uint64_t x)
static CService ip(uint32_t i)
#define LogPrint(category,...)
Transaction validation functions.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
bool LookupHost(const std::string &name, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
int RPCSerializationFlags()
Parameters that influence chain consensus.
static const int PROTOCOL_VERSION
network protocol versioning
static const char * MSG_HASHBLOCK
static const char * MSG_SEQUENCE
static const char * MSG_RAWBLOCK
static bool SendSequenceMsg(CZMQAbstractPublishNotifier ¬ifier, uint256 hash, char label, std::optional< uint64_t > sequence={})
static bool IsZMQAddressIPV6(const std::string &zmq_address)
static std::multimap< std::string, CZMQAbstractPublishNotifier * > mapPublishNotifiers
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 std::string &str)