8#include <chainparams.h>
59 int rc = zmq_msg_init_size(&
msg, size);
62 zmqError(
"Unable to initialize ZMQ msg");
67 void *buf = zmq_msg_data(&
msg);
68 memcpy(buf,
data, size);
72 rc = zmq_msg_send(&
msg, sock,
data ? ZMQ_SNDMORE : 0);
86 size = va_arg(
args,
size_t);
94 const std::string tcp_prefix =
"tcp://";
95 const size_t tcp_index = zmq_address.rfind(tcp_prefix);
96 const size_t colon_index = zmq_address.rfind(
':');
97 if (tcp_index == 0 && colon_index != std::string::npos) {
98 const std::string
ip = zmq_address.substr(tcp_prefix.length(), colon_index - tcp_prefix.length());
99 const std::optional<CNetAddr> addr{
LookupHost(
ip,
false)};
100 if (addr.has_value() && addr.value().IsIPv6())
return true;
114 psocket = zmq_socket(pcontext, ZMQ_PUB);
117 zmqError(
"Failed to create socket");
126 zmqError(
"Failed to set outbound message high water mark");
131 const int so_keepalive_option {1};
132 rc = zmq_setsockopt(
psocket, ZMQ_TCP_KEEPALIVE, &so_keepalive_option,
sizeof(so_keepalive_option));
134 zmqError(
"Failed to set SO_KEEPALIVE");
141 rc = zmq_setsockopt(
psocket, ZMQ_IPV6, &enable_ipv6,
sizeof(enable_ipv6));
180 typedef std::multimap<std::string, CZMQAbstractPublishNotifier*>::iterator iterator;
183 for (iterator it = iterpair.first; it != iterpair.second; ++it)
185 if (it->second==
this)
196 zmq_setsockopt(
psocket, ZMQ_LINGER, &linger,
sizeof(linger));
208 unsigned char msgseq[
sizeof(uint32_t)];
225 for (
unsigned int i = 0; i < 32; i++) {
236 for (
unsigned int i = 0; i < 32; i++) {
246 std::vector<uint8_t> block{};
248 zmqError(
"Can't read block from disk");
268 unsigned char data[
sizeof(hash) +
sizeof(label) +
sizeof(uint64_t)];
269 for (
unsigned int i = 0; i <
sizeof(hash); ++i) {
270 data[
sizeof(hash) - 1 - i] = hash.
begin()[i];
272 data[
sizeof(hash)] = label;
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
The basic transaction that is broadcasted on the network and contained in blocks.
const Txid & GetHash() const LIFETIMEBOUND
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
const std::function< bool(std::vector< uint8_t > &, const CBlockIndex &)> m_get_block_by_index
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
Double ended buffer combining vector and stream-like interfaces.
const_iterator begin() const
constexpr unsigned char * begin()
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 LogDebug(category,...)
Transaction validation functions.
std::vector< CNetAddr > LookupHost(const std::string &name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
static constexpr TransactionSerParams TX_WITH_WITNESS
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)