Electroneum
push_core_event_visitor< t_test_class > Struct Template Reference

#include <chaingen.h>

Inheritance diagram for push_core_event_visitor< t_test_class >:
Collaboration diagram for push_core_event_visitor< t_test_class >:

Public Member Functions

 push_core_event_visitor (cryptonote::core &c, const std::vector< test_event_entry > &events, t_test_class &validator)
 
void event_index (size_t ev_index)
 
bool operator() (const event_replay_settings &settings)
 
bool operator() (const event_visitor_settings &settings)
 
bool operator() (const cryptonote::transaction &tx) const
 
bool operator() (const std::vector< cryptonote::transaction > &txs) const
 
bool operator() (const cryptonote::block &b) const
 
bool operator() (const callback_entry &cb) const
 
bool operator() (const cryptonote::account_base &ab) const
 
bool operator() (const serialized_block &sr_block) const
 
bool operator() (const serialized_transaction &sr_tx) const
 

Detailed Description

template<class t_test_class>
struct push_core_event_visitor< t_test_class >

Definition at line 499 of file chaingen.h.

Constructor & Destructor Documentation

◆ push_core_event_visitor()

template<class t_test_class>
push_core_event_visitor< t_test_class >::push_core_event_visitor ( cryptonote::core c,
const std::vector< test_event_entry > &  events,
t_test_class &  validator 
)
inline

Definition at line 510 of file chaingen.h.

511  : m_c(c)
512  , m_events(events)
513  , m_validator(validator)
514  , m_ev_index(0)
515  , m_txs_keeped_by_block(false)
516  {
517  }

Member Function Documentation

◆ event_index()

template<class t_test_class>
void push_core_event_visitor< t_test_class >::event_index ( size_t  ev_index)
inline

Definition at line 519 of file chaingen.h.

520  {
521  m_ev_index = ev_index;
522  }
Here is the caller graph for this function:

◆ operator()() [1/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const event_replay_settings settings)
inline

Definition at line 524 of file chaingen.h.

525  {
526  log_event("event_replay_settings");
527  return true;
528  }

◆ operator()() [2/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const event_visitor_settings settings)
inline

Definition at line 530 of file chaingen.h.

531  {
532  log_event("event_visitor_settings");
533 
535  {
536  m_txs_keeped_by_block = settings.txs_keeped_by_block;
537  }
538 
539  return true;
540  }

◆ operator()() [3/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const cryptonote::transaction tx) const
inline

Definition at line 542 of file chaingen.h.

543  {
544  log_event("cryptonote::transaction");
545 
547  size_t pool_size = m_c.get_pool_transactions_count();
548  m_c.handle_incoming_tx(t_serializable_object_to_blob(tx), tvc, m_txs_keeped_by_block, false, false);
549  bool tx_added = pool_size + 1 == m_c.get_pool_transactions_count();
550  bool r = m_validator.check_tx_verification_context(tvc, tx_added, m_ev_index, tx);
551  CHECK_AND_NO_ASSERT_MES(r, false, "tx verification context check failed");
552  return true;
553  }
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:189
bool handle_incoming_tx(const blobdata &tx_blob, tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
handles an incoming transaction
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
Here is the call graph for this function:

◆ operator()() [4/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const std::vector< cryptonote::transaction > &  txs) const
inline

Definition at line 555 of file chaingen.h.

556  {
557  log_event("cryptonote::transaction");
558 
559  std::vector<cryptonote::blobdata> tx_blobs;
560  std::vector<cryptonote::tx_verification_context> tvcs;
562  for (const auto &tx: txs)
563  {
564  tx_blobs.push_back(t_serializable_object_to_blob(tx));
565  tvcs.push_back(tvc0);
566  }
567  size_t pool_size = m_c.get_pool_transactions_count();
568  m_c.handle_incoming_txs(tx_blobs, tvcs, m_txs_keeped_by_block, false, false);
569  size_t tx_added = m_c.get_pool_transactions_count() - pool_size;
570  bool r = m_validator.check_tx_verification_context_array(tvcs, tx_added, m_ev_index, txs);
571  CHECK_AND_NO_ASSERT_MES(r, false, "tx verification context check failed");
572  return true;
573  }
bool handle_incoming_txs(const std::vector< blobdata > &tx_blobs, std::vector< tx_verification_context > &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
handles a list of incoming transactions
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:189
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
Here is the call graph for this function:

◆ operator()() [5/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const cryptonote::block b) const
inline

Definition at line 575 of file chaingen.h.

576  {
577  log_event("cryptonote::block");
578 
581  std::vector<cryptonote::block> pblocks;
582  if (m_c.prepare_handle_incoming_blocks(std::vector<cryptonote::block_complete_entry>(1, {bd, {}}), pblocks))
583  {
584  m_c.handle_incoming_block(bd, &b, bvc);
586  }
587  else
588  bvc.m_verification_failed = true;
589  bool r = m_validator.check_block_verification_context(bvc, m_ev_index, b);
590  CHECK_AND_NO_ASSERT_MES(r, false, "block verification context check failed");
591  return r;
592  }
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:189
bool prepare_handle_incoming_blocks(const std::vector< block_complete_entry > &blocks_entry, std::vector< block > &blocks)
performs some preprocessing on a group of incoming blocks to speed up verification ...
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block
std::string blobdata
Definition: blobdatatype.h:39
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
Here is the call graph for this function:

◆ operator()() [6/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const callback_entry cb) const
inline

Definition at line 594 of file chaingen.h.

595  {
596  log_event(std::string("callback_entry ") + cb.callback_name);
597  return m_validator.verify(cb.callback_name, m_c, m_ev_index, m_events);
598  }
std::string callback_name
Definition: chaingen.h:67
::std::string string
Definition: gtest-port.h:1097

◆ operator()() [7/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const cryptonote::account_base ab) const
inline

Definition at line 600 of file chaingen.h.

601  {
602  log_event("cryptonote::account_base");
603  return true;
604  }

◆ operator()() [8/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const serialized_block sr_block) const
inline

Definition at line 606 of file chaingen.h.

607  {
608  log_event("serialized_block");
609 
611  std::vector<cryptonote::block> pblocks;
612  if (m_c.prepare_handle_incoming_blocks(std::vector<cryptonote::block_complete_entry>(1, {sr_block.data, {}}), pblocks))
613  {
614  m_c.handle_incoming_block(sr_block.data, NULL, bvc);
616  }
617  else
618  bvc.m_verification_failed = true;
619 
620  cryptonote::block blk;
621  std::stringstream ss;
622  ss << sr_block.data;
623  binary_archive<false> ba(ss);
625  if (!ss.good())
626  {
627  blk = cryptonote::block();
628  }
629  bool r = m_validator.check_block_verification_context(bvc, m_ev_index, blk);
630  CHECK_AND_NO_ASSERT_MES(r, false, "block verification context check failed");
631  return true;
632  }
cryptonote::blobdata data
Definition: chaingen.h:92
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:189
bool prepare_handle_incoming_blocks(const std::vector< block_complete_entry > &blocks_entry, std::vector< block > &blocks)
performs some preprocessing on a group of incoming blocks to speed up verification ...
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
void serialize(Archive &a, unsigned_tx_set &x, const boost::serialization::version_type ver)
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
Here is the call graph for this function:

◆ operator()() [9/9]

template<class t_test_class>
bool push_core_event_visitor< t_test_class >::operator() ( const serialized_transaction sr_tx) const
inline

Definition at line 634 of file chaingen.h.

635  {
636  log_event("serialized_transaction");
637 
639  size_t pool_size = m_c.get_pool_transactions_count();
640  m_c.handle_incoming_tx(sr_tx.data, tvc, m_txs_keeped_by_block, false, false);
641  bool tx_added = pool_size + 1 == m_c.get_pool_transactions_count();
642 
644  std::stringstream ss;
645  ss << sr_tx.data;
646  binary_archive<false> ba(ss);
648  if (!ss.good())
649  {
651  }
652 
653  bool r = m_validator.check_tx_verification_context(tvc, tx_added, m_ev_index, tx);
654  CHECK_AND_NO_ASSERT_MES(r, false, "transaction verification context check failed");
655  return true;
656  }
cryptonote::blobdata data
Definition: chaingen.h:92
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:189
bool handle_incoming_tx(const blobdata &tx_blob, tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
handles an incoming transaction
void serialize(Archive &a, unsigned_tx_set &x, const boost::serialization::version_type ver)
size_t get_pool_transactions_count() const
get the total number of transactions in the pool
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
Here is the call graph for this function:

The documentation for this struct was generated from the following file: