Kagome
Polkadot Runtime Engine in C++17
kagome::telemetry::TelemetryServiceImpl Class Reference

#include <service_impl.hpp>

Inheritance diagram for kagome::telemetry::TelemetryServiceImpl:
Collaboration diagram for kagome::telemetry::TelemetryServiceImpl:

Public Member Functions

 TelemetryServiceImpl (std::shared_ptr< application::AppStateManager > app_state_manager, const application::AppConfiguration &app_configuration, const application::ChainSpec &chain_spec, const libp2p::Host &host, std::shared_ptr< const transaction_pool::TransactionPool > tx_pool, std::shared_ptr< const storage::BufferStorage > buffer_storage, std::shared_ptr< const network::PeerManager > peer_manager)
 
 TelemetryServiceImpl (const TelemetryServiceImpl &)=delete
 
 TelemetryServiceImpl (TelemetryServiceImpl &&)=delete
 
TelemetryServiceImploperator= (const TelemetryServiceImpl &)=delete
 
TelemetryServiceImploperator= (TelemetryServiceImpl &&)=delete
 
void notifyBlockImported (const primitives::BlockInfo &info, BlockOrigin origin) override
 
void notifyBlockFinalized (const primitives::BlockInfo &info) override
 
void setGenesisBlockHash (const primitives::BlockHash &hash) override
 
void notifyWasSynchronized () override
 
bool isEnabled () const override
 
- Public Member Functions inherited from kagome::telemetry::TelemetryService
virtual ~TelemetryService ()=default
 

Private Types

using WorkGuardT = boost::asio::executor_work_guard< boost::asio::io_context::executor_type >
 

Private Member Functions

bool prepare ()
 
bool start ()
 
void stop ()
 
std::vector< TelemetryEndpointchainSpecEndpoints () const
 parse telemetry endpoints from chain specification More...
 
std::string connectedMessage ()
 produces the greeting message for the (re-)established connections More...
 
void frequentNotificationsRoutine ()
 produces and sends notifications about best and finalized block More...
 
void delayedNotificationsRoutine ()
 produces and sends system health notifications More...
 
void prepareGreetingMessage ()
 
std::string blockNotification (const primitives::BlockInfo &info, std::optional< BlockOrigin > origin)
 
std::string systemIntervalMessage1 ()
 compose system health notification of the first format More...
 
std::string systemIntervalMessage2 ()
 compose system health notification of the second format More...
 
std::string currentTimestamp () const
 

Private Attributes

std::shared_ptr< application::AppStateManagerapp_state_manager_
 
const application::AppConfigurationapp_configuration_
 
const application::ChainSpecchain_spec_
 
const libp2p::Host & host_
 
std::shared_ptr< const transaction_pool::TransactionPooltx_pool_
 
std::shared_ptr< const storage::BufferStoragebuffer_storage_
 
std::shared_ptr< const network::PeerManagerpeer_manager_
 
const bool enabled_
 
volatile bool shutdown_requested_ = false
 
std::shared_ptr< libp2p::basic::Scheduler > scheduler_
 
std::shared_ptr< WorkGuardTwork_guard_
 
std::shared_ptr< boost::asio::io_context > io_context_
 
std::shared_ptr< std::thread > worker_thread_
 
std::vector< std::shared_ptr< TelemetryConnection > > connections_
 
libp2p::basic::Scheduler::Handle frequent_timer_
 
libp2p::basic::Scheduler::Handle delayed_timer_
 
common::spin_lock cache_mutex_
 
struct {
bool is_set = false
 
primitives::BlockInfo block {0, {}}
 
BlockOrigin origin
 
last_imported_
 
struct {
primitives::BlockNumber reported = 0
 
primitives::BlockInfo block {0, {}}
 
last_finalized_
 
log::Logger log_
 
rapidjson::Document greeting_json_
 
std::string genesis_hash_
 
std::shared_ptr< MessagePoolmessage_pool_
 
bool was_synchronized_ = false
 

Detailed Description

Definition at line 46 of file service_impl.hpp.

Member Typedef Documentation

using kagome::telemetry::TelemetryServiceImpl::WorkGuardT = boost::asio::executor_work_guard< boost::asio::io_context::executor_type>
private

Definition at line 137 of file service_impl.hpp.

Constructor & Destructor Documentation

kagome::telemetry::TelemetryServiceImpl::TelemetryServiceImpl ( std::shared_ptr< application::AppStateManager app_state_manager,
const application::AppConfiguration app_configuration,
const application::ChainSpec chain_spec,
const libp2p::Host &  host,
std::shared_ptr< const transaction_pool::TransactionPool tx_pool,
std::shared_ptr< const storage::BufferStorage buffer_storage,
std::shared_ptr< const network::PeerManager peer_manager 
)

Definition at line 39 of file service_impl.cpp.

kagome::telemetry::TelemetryServiceImpl::TelemetryServiceImpl ( const TelemetryServiceImpl )
delete
kagome::telemetry::TelemetryServiceImpl::TelemetryServiceImpl ( TelemetryServiceImpl &&  )
delete

Member Function Documentation

std::string kagome::telemetry::TelemetryServiceImpl::blockNotification ( const primitives::BlockInfo info,
std::optional< BlockOrigin origin 
)
private

Produces "block.imported" or "notify.finalized" JSON telemetry messages

Parameters
info- block info to notify about
origin- if set, then "block.imported" event produced, otherwise "notify.finalized"
Returns
string with event JSON

Definition at line 322 of file service_impl.cpp.

std::vector< TelemetryEndpoint > kagome::telemetry::TelemetryServiceImpl::chainSpecEndpoints ( ) const
private

parse telemetry endpoints from chain specification

Definition at line 125 of file service_impl.cpp.

std::string kagome::telemetry::TelemetryServiceImpl::connectedMessage ( )
private

produces the greeting message for the (re-)established connections

Definition at line 291 of file service_impl.cpp.

std::string kagome::telemetry::TelemetryServiceImpl::currentTimestamp ( ) const
private
Returns
RFC3339 formatted current timestamp string

Definition at line 283 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::delayedNotificationsRoutine ( )
private

produces and sends system health notifications

Definition at line 223 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::frequentNotificationsRoutine ( )
private

produces and sends notifications about best and finalized block

Definition at line 187 of file service_impl.cpp.

bool kagome::telemetry::TelemetryServiceImpl::isEnabled ( ) const
overridevirtual

Telemetry service status

Returns
true - when application configured to broadcast telemetry

Implements kagome::telemetry::TelemetryService.

Definition at line 473 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::notifyBlockFinalized ( const primitives::BlockInfo info)
overridevirtual

Inform about the last finalized block

Parameters
info- block info

Implements kagome::telemetry::TelemetryService.

Definition at line 311 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::notifyBlockImported ( const primitives::BlockInfo info,
BlockOrigin  origin 
)
overridevirtual

Inform about last known block

Parameters
info- block info
origin- source of the block

Implements kagome::telemetry::TelemetryService.

Definition at line 300 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::notifyWasSynchronized ( )
overridevirtual

Let the telemetry service know that the node has been in a synchronized state at least once.

After this call all kNetworkInitialSync events will be treated as kNetworkBroadcast

Implements kagome::telemetry::TelemetryService.

Definition at line 469 of file service_impl.cpp.

TelemetryServiceImpl& kagome::telemetry::TelemetryServiceImpl::operator= ( const TelemetryServiceImpl )
delete
TelemetryServiceImpl& kagome::telemetry::TelemetryServiceImpl::operator= ( TelemetryServiceImpl &&  )
delete
bool kagome::telemetry::TelemetryServiceImpl::prepare ( )
private

Definition at line 77 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::prepareGreetingMessage ( )
private

Constructs the main and immutable part of JSON to be serialized later as greeting message on new telemetry connections.

Definition at line 245 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::setGenesisBlockHash ( const primitives::BlockHash hash)
overridevirtual

Used to initially inform the service about the genesis hash.

Parameters
hashgenesis hash for the network

Allows to avoid circular references in classes dependency tree

Implements kagome::telemetry::TelemetryService.

Definition at line 464 of file service_impl.cpp.

bool kagome::telemetry::TelemetryServiceImpl::start ( )
private

Definition at line 104 of file service_impl.cpp.

void kagome::telemetry::TelemetryServiceImpl::stop ( )
private

Definition at line 115 of file service_impl.cpp.

std::string kagome::telemetry::TelemetryServiceImpl::systemIntervalMessage1 ( )
private

compose system health notification of the first format

Definition at line 386 of file service_impl.cpp.

std::string kagome::telemetry::TelemetryServiceImpl::systemIntervalMessage2 ( )
private

compose system health notification of the second format

Definition at line 428 of file service_impl.cpp.

Member Data Documentation

const application::AppConfiguration& kagome::telemetry::TelemetryServiceImpl::app_configuration_
private

Definition at line 125 of file service_impl.hpp.

std::shared_ptr<application::AppStateManager> kagome::telemetry::TelemetryServiceImpl::app_state_manager_
private

Definition at line 124 of file service_impl.hpp.

std::shared_ptr<const storage::BufferStorage> kagome::telemetry::TelemetryServiceImpl::buffer_storage_
private

Definition at line 129 of file service_impl.hpp.

common::spin_lock kagome::telemetry::TelemetryServiceImpl::cache_mutex_
private

Definition at line 146 of file service_impl.hpp.

const application::ChainSpec& kagome::telemetry::TelemetryServiceImpl::chain_spec_
private

Definition at line 126 of file service_impl.hpp.

std::vector<std::shared_ptr<TelemetryConnection> > kagome::telemetry::TelemetryServiceImpl::connections_
private

Definition at line 141 of file service_impl.hpp.

libp2p::basic::Scheduler::Handle kagome::telemetry::TelemetryServiceImpl::delayed_timer_
private

Definition at line 143 of file service_impl.hpp.

const bool kagome::telemetry::TelemetryServiceImpl::enabled_
private

Definition at line 131 of file service_impl.hpp.

libp2p::basic::Scheduler::Handle kagome::telemetry::TelemetryServiceImpl::frequent_timer_
private

Definition at line 142 of file service_impl.hpp.

std::string kagome::telemetry::TelemetryServiceImpl::genesis_hash_
private

Definition at line 160 of file service_impl.hpp.

rapidjson::Document kagome::telemetry::TelemetryServiceImpl::greeting_json_
private

Definition at line 159 of file service_impl.hpp.

const libp2p::Host& kagome::telemetry::TelemetryServiceImpl::host_
private

Definition at line 127 of file service_impl.hpp.

std::shared_ptr<boost::asio::io_context> kagome::telemetry::TelemetryServiceImpl::io_context_
private

Definition at line 139 of file service_impl.hpp.

struct { ... } kagome::telemetry::TelemetryServiceImpl::last_finalized_
struct { ... } kagome::telemetry::TelemetryServiceImpl::last_imported_
log::Logger kagome::telemetry::TelemetryServiceImpl::log_
private

Definition at line 158 of file service_impl.hpp.

std::shared_ptr<MessagePool> kagome::telemetry::TelemetryServiceImpl::message_pool_
private

Definition at line 161 of file service_impl.hpp.

std::shared_ptr<const network::PeerManager> kagome::telemetry::TelemetryServiceImpl::peer_manager_
private

Definition at line 130 of file service_impl.hpp.

std::shared_ptr<libp2p::basic::Scheduler> kagome::telemetry::TelemetryServiceImpl::scheduler_
private

Definition at line 135 of file service_impl.hpp.

volatile bool kagome::telemetry::TelemetryServiceImpl::shutdown_requested_ = false
private

Definition at line 134 of file service_impl.hpp.

std::shared_ptr<const transaction_pool::TransactionPool> kagome::telemetry::TelemetryServiceImpl::tx_pool_
private

Definition at line 128 of file service_impl.hpp.

bool kagome::telemetry::TelemetryServiceImpl::was_synchronized_ = false
private

Definition at line 162 of file service_impl.hpp.

std::shared_ptr<WorkGuardT> kagome::telemetry::TelemetryServiceImpl::work_guard_
private

Definition at line 138 of file service_impl.hpp.

std::shared_ptr<std::thread> kagome::telemetry::TelemetryServiceImpl::worker_thread_
private

Definition at line 140 of file service_impl.hpp.


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