Monero
Loading...
Searching...
No Matches
cryptonote::listener::zmq_pub Class Reference

Sends ZMQ PUB messages on cryptonote events. More...

#include <zmq_pub.h>

Classes

struct  chain_main
 Callable for send_chain_main with weak ownership to zmq_pub object. More...
struct  miner_data
 Callable for send_miner_data with weak ownership to zmq_pub object. More...
struct  txpool_add
 Callable for send_txpool_add with weak ownership to zmq_pub object. More...

Public Member Functions

 zmq_pub (void *context)
 zmq_pub (const zmq_pub &)=delete
 zmq_pub (zmq_pub &&)=delete
 ~zmq_pub ()
zmq_puboperator= (const zmq_pub &)=delete
zmq_puboperator= (zmq_pub &&)=delete
bool sub_request (const boost::string_ref message)
 Process a client subscription request (from XPUB sockets). Thread-safe.
bool relay_to_pub (void *relay, void *pub)
std::size_t send_chain_main (std::uint64_t height, epee::span< const cryptonote::block > blocks)
std::size_t send_miner_data (uint8_t major_version, uint64_t height, const crypto::hash &prev_id, const crypto::hash &seed_hash, difficulty_type diff, uint64_t median_weight, uint64_t already_generated_coins, const std::vector< tx_block_template_backlog_entry > &tx_backlog)
std::size_t send_txpool_add (std::vector< cryptonote::txpool_event > txes)

Static Public Member Functions

static constexpr const char * relay_endpoint () noexcept

Private Attributes

net::zmq::socket relay_
std::deque< std::vector< txpool_event > > txes_
std::array< std::size_t, 2 > chain_subs_
std::array< std::size_t, 1 > miner_subs_
std::array< std::size_t, 2 > txpool_subs_
boost::mutex sync_
 Synchronizes counts in *_subs_ arrays.

Detailed Description

Sends ZMQ PUB messages on cryptonote events.

Clients must ensure that all transaction(s) are notified before any blocks they are contained in, and must ensure that each block is notified in chain order. An external lock must be held by clients during the entire txpool check and notification sequence and (a possibly second) lock is held during the entire block check and notification sequence. Otherwise, events could be sent in a different order than processed.

Constructor & Destructor Documentation

◆ zmq_pub() [1/3]

cryptonote::listener::zmq_pub::zmq_pub ( void * context)
explicit

◆ zmq_pub() [2/3]

cryptonote::listener::zmq_pub::zmq_pub ( const zmq_pub & )
delete

◆ zmq_pub() [3/3]

cryptonote::listener::zmq_pub::zmq_pub ( zmq_pub && )
delete

◆ ~zmq_pub()

cryptonote::listener::zmq_pub::~zmq_pub ( )

Member Function Documentation

◆ operator=() [1/2]

zmq_pub & cryptonote::listener::zmq_pub::operator= ( const zmq_pub & )
delete

◆ operator=() [2/2]

zmq_pub & cryptonote::listener::zmq_pub::operator= ( zmq_pub && )
delete

◆ relay_endpoint()

constexpr const char * cryptonote::listener::zmq_pub::relay_endpoint ( )
inlinestaticconstexprnoexcept
Returns
Name of ZMQ_PAIR endpoint for pub notifications

◆ relay_to_pub()

bool cryptonote::listener::zmq_pub::relay_to_pub ( void * relay,
void * pub )

Forward ZMQ messages sent to relay via send_chain_main or send_txpool_add to pub. Used by ZmqServer.

◆ send_chain_main()

std::size_t cryptonote::listener::zmq_pub::send_chain_main ( std::uint64_t height,
epee::span< const cryptonote::block > blocks )

Send a ZMQ_PUB notification for a change to the main chain. Thread-safe.

Returns
Number of ZMQ messages sent to relay.

◆ send_miner_data()

std::size_t cryptonote::listener::zmq_pub::send_miner_data ( uint8_t major_version,
uint64_t height,
const crypto::hash & prev_id,
const crypto::hash & seed_hash,
difficulty_type diff,
uint64_t median_weight,
uint64_t already_generated_coins,
const std::vector< tx_block_template_backlog_entry > & tx_backlog )

Send a ZMQ_PUB notification for a new miner data. Thread-safe.

Returns
Number of ZMQ messages sent to relay.

◆ send_txpool_add()

std::size_t cryptonote::listener::zmq_pub::send_txpool_add ( std::vector< cryptonote::txpool_event > txes)

Send a ZMQ_PUB notification for new tx(es) being added to the local pool. Thread-safe.

Returns
Number of ZMQ messages sent to relay.

◆ sub_request()

bool cryptonote::listener::zmq_pub::sub_request ( const boost::string_ref message)

Process a client subscription request (from XPUB sockets). Thread-safe.

Member Data Documentation

◆ chain_subs_

std::array<std::size_t, 2> cryptonote::listener::zmq_pub::chain_subs_
private

◆ miner_subs_

std::array<std::size_t, 1> cryptonote::listener::zmq_pub::miner_subs_
private

◆ relay_

net::zmq::socket cryptonote::listener::zmq_pub::relay_
private

◆ sync_

boost::mutex cryptonote::listener::zmq_pub::sync_
private

Synchronizes counts in *_subs_ arrays.

◆ txes_

std::deque<std::vector<txpool_event> > cryptonote::listener::zmq_pub::txes_
private

◆ txpool_subs_

std::array<std::size_t, 2> cryptonote::listener::zmq_pub::txpool_subs_
private

The documentation for this class was generated from the following files: