45 int rc = zmq_msg_init_size(&msg, size);
48 zmqError(
"Unable to initialize ZMQ msg");
53 void *buf = zmq_msg_data(&msg);
54 memcpy(buf, data, size);
56 data = va_arg(
args,
const void*);
58 rc = zmq_msg_send(&msg, sock, data ? ZMQ_SNDMORE : 0);
72 size = va_arg(
args,
size_t);
80 const std::string tcp_prefix =
"tcp://";
81 const size_t tcp_index = zmq_address.rfind(tcp_prefix);
82 const size_t colon_index = zmq_address.rfind(
":");
83 if (tcp_index == 0 && colon_index != std::string::npos) {
84 const std::string
ip = zmq_address.substr(tcp_prefix.length(), colon_index - tcp_prefix.length());
87 if (addr.
IsIPv6())
return true;
101 psocket = zmq_socket(pcontext, ZMQ_PUB);
104 zmqError(
"Failed to create socket");
113 zmqError(
"Failed to set outbound message high water mark");
118 const int so_keepalive_option {1};
119 rc = zmq_setsockopt(
psocket, ZMQ_TCP_KEEPALIVE, &so_keepalive_option,
sizeof(so_keepalive_option));
121 zmqError(
"Failed to set SO_KEEPALIVE");
128 rc = zmq_setsockopt(
psocket, ZMQ_IPV6, &enable_ipv6,
sizeof(enable_ipv6));
167 typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
170 for (iterator it = iterpair.first; it != iterpair.second; ++it)
172 if (it->second==
this)
183 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
195 unsigned char msgseq[
sizeof(uint32_t)];
212 for (
unsigned int i = 0; i < 32; i++) {
213 data[31 - i] = hash.
begin()[i];
223 for (
unsigned int i = 0; i < 32; i++) {
224 data[31 - i] = hash.
begin()[i];
240 zmqError(
"Can't read block from disk");
263 unsigned char data[
sizeof(hash) +
sizeof(label) +
sizeof(uint64_t)];
264 for (
unsigned int i = 0; i <
sizeof(hash); ++i) {
265 data[
sizeof(hash) - 1 - i] = hash.
begin()[i];
267 data[
sizeof(hash)] = label;
268 if (sequence)
WriteLE64(data +
sizeof(hash) +
sizeof(label), *sequence);
static const char * MSG_HASHBLOCK
bool NotifyTransaction(const CTransaction &transaction) override
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
uint32_t nSequence
upcounting per message sequence number
#define LogPrint(category,...)
bool NotifyBlockDisconnect(const CBlockIndex *pindex) override
bool SendZmqMessage(const char *command, const void *data, size_t size)
static std::multimap< std::string, CZMQAbstractPublishNotifier * > mapPublishNotifiers
static bool SendSequenceMsg(CZMQAbstractPublishNotifier ¬ifier, uint256 hash, char label, std::optional< uint64_t > sequence={})
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.
Double ended buffer combining vector and stream-like interfaces.
static const char * MSG_HASHTX
bool NotifyTransaction(const CTransaction &transaction) override
bool NotifyBlock(const CBlockIndex *pindex) override
uint256 GetBlockHash() const
const uint256 & GetHash() const
bool NotifyBlock(const CBlockIndex *pindex) override
static void WriteLE32(unsigned char *ptr, uint32_t x)
static int zmq_send_multipart(void *sock, const void *data, size_t size,...)
static CService ip(uint32_t i)
Parameters that influence chain consensus.
static bool IsZMQAddressIPV6(const std::string &zmq_address)
void zmqError(const std::string &str)
bool NotifyTransactionAcceptance(const CTransaction &transaction, uint64_t mempool_sequence) override
static const char * MSG_RAWTX
const_iterator begin() const
static const char * MSG_RAWBLOCK
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()
static const int PROTOCOL_VERSION
network protocol versioning
bool NotifyTransactionRemoval(const CTransaction &transaction, uint64_t mempool_sequence) override
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
std::string GetHex() const
int outbound_message_high_water_mark
bool NotifyBlockConnect(const CBlockIndex *pindex) override
static void WriteLE64(unsigned char *ptr, uint64_t x)
The basic transaction that is broadcasted on the network and contained in blocks. ...
const Consensus::Params & GetConsensus() const
static const char * MSG_SEQUENCE
bool Initialize(void *pcontext) override