Electroneum
tests::proxy_core Class Reference

#include <core_proxy.h>

Public Member Functions

void on_synchronized ()
 
void safesyncmode (const bool)
 
uint64_t get_current_blockchain_height ()
 
void set_target_blockchain_height (uint64_t)
 
bool init (const boost::program_options::variables_map &vm)
 
bool deinit ()
 
bool get_short_chain_history (std::list< crypto::hash > &ids)
 
bool get_stat_info (cryptonote::core_stat_info &st_inf)
 
bool have_block (const crypto::hash &id)
 
void get_blockchain_top (uint64_t &height, crypto::hash &top_id)
 
bool handle_incoming_tx (const cryptonote::blobdata &tx_blob, cryptonote::tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
 
bool handle_incoming_txs (const std::vector< cryptonote::blobdata > &tx_blobs, std::vector< cryptonote::tx_verification_context > &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
 
bool handle_incoming_block (const cryptonote::blobdata &block_blob, const cryptonote::block *block, cryptonote::block_verification_context &bvc, bool update_miner_blocktemplate=true)
 
void pause_mine ()
 
void resume_mine ()
 
bool on_idle ()
 
bool find_blockchain_supplement (const std::list< crypto::hash > &qblock_ids, cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp)
 
bool handle_get_objects (cryptonote::NOTIFY_REQUEST_GET_OBJECTS::request &arg, cryptonote::NOTIFY_RESPONSE_GET_OBJECTS::request &rsp, cryptonote::cryptonote_connection_context &context)
 
cryptonote::Blockchainget_blockchain_storage ()
 
bool get_test_drop_download ()
 
bool get_test_drop_download_height ()
 
bool prepare_handle_incoming_blocks (const std::vector< cryptonote::block_complete_entry > &blocks_entry, std::vector< cryptonote::block > &blocks)
 
bool cleanup_handle_incoming_blocks (bool force_sync=false)
 
uint64_t get_target_blockchain_height () const
 
size_t get_block_sync_size (uint64_t height) const
 
virtual void on_transaction_relayed (const cryptonote::blobdata &tx)
 
cryptonote::network_type get_nettype () const
 
bool get_pool_transaction (const crypto::hash &id, cryptonote::blobdata &tx_blob) const
 
bool pool_has_tx (const crypto::hash &txid) const
 
bool get_blocks (uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, cryptonote::block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
 
bool get_transactions (const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::transaction > &txs, std::vector< crypto::hash > &missed_txs) const
 
bool get_block_by_hash (const crypto::hash &h, cryptonote::block &blk, bool *orphan=NULL) const
 
uint8_t get_ideal_hard_fork_version () const
 
uint8_t get_ideal_hard_fork_version (uint64_t height) const
 
uint8_t get_hard_fork_version (uint64_t height) const
 
uint64_t get_earliest_ideal_height_for_version (uint8_t version) const
 
cryptonote::difficulty_type get_block_cumulative_difficulty (uint64_t height) const
 
bool fluffy_blocks_enabled () const
 
uint64_t prevalidate_block_hashes (uint64_t height, const std::vector< crypto::hash > &hashes)
 
bool pad_transactions () const
 
uint32_t get_blockchain_pruning_seed () const
 
bool prune_blockchain (uint32_t pruning_seed) const
 
void set_block_cumulative_difficulty (uint64_t height, cryptonote::difficulty_type diff)
 
electroneum::basic::list_update_outcome set_validators_list (std::string v_list, bool isEmergencyUpdate=false)
 
bool isValidatorsListValid ()
 
std::string get_validators_list ()
 

Detailed Description

Definition at line 55 of file core_proxy.h.

Member Function Documentation

◆ cleanup_handle_incoming_blocks()

bool tests::proxy_core::cleanup_handle_incoming_blocks ( bool  force_sync = false)
inline

Definition at line 91 of file core_proxy.h.

91 { return true; }

◆ deinit()

bool tests::proxy_core::deinit ( )
inline

Definition at line 74 of file core_proxy.h.

74 {return true;}
Here is the caller graph for this function:

◆ find_blockchain_supplement()

bool tests::proxy_core::find_blockchain_supplement ( const std::list< crypto::hash > &  qblock_ids,
cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request resp 
)
inline

Definition at line 85 of file core_proxy.h.

85 {return true;}

◆ fluffy_blocks_enabled()

bool tests::proxy_core::fluffy_blocks_enabled ( ) const
inline

Definition at line 106 of file core_proxy.h.

106 { return false; }

◆ get_block_by_hash()

bool tests::proxy_core::get_block_by_hash ( const crypto::hash h,
cryptonote::block blk,
bool orphan = NULL 
) const
inline

Definition at line 100 of file core_proxy.h.

100 { return false; }

◆ get_block_cumulative_difficulty()

cryptonote::difficulty_type tests::proxy_core::get_block_cumulative_difficulty ( uint64_t  height) const
inline

Definition at line 105 of file core_proxy.h.

105 { return 0; }

◆ get_block_sync_size()

size_t tests::proxy_core::get_block_sync_size ( uint64_t  height) const
inline

Definition at line 93 of file core_proxy.h.

#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT

◆ get_blockchain_pruning_seed()

uint32_t tests::proxy_core::get_blockchain_pruning_seed ( ) const
inline

Definition at line 109 of file core_proxy.h.

109 { return 0; }

◆ get_blockchain_storage()

cryptonote::Blockchain& tests::proxy_core::get_blockchain_storage ( )
inline

Definition at line 87 of file core_proxy.h.

87 { throw std::runtime_error("Called invalid member function: please never call get_blockchain_storage on the TESTING class proxy_core."); }

◆ get_blockchain_top()

void tests::proxy_core::get_blockchain_top ( uint64_t height,
crypto::hash top_id 
)

Definition at line 232 of file core_proxy.cpp.

232  {
233  height = 0;
234  top_id = get_block_hash(m_genesis);
235 }
uint64_t height
Definition: blockchain.cpp:91
crypto::hash get_block_hash(uint64_t height)
Here is the call graph for this function:

◆ get_blocks()

bool tests::proxy_core::get_blocks ( uint64_t  start_offset,
size_t  count,
std::vector< std::pair< cryptonote::blobdata, cryptonote::block >> &  blocks,
std::vector< cryptonote::blobdata > &  txs 
) const
inline

Definition at line 98 of file core_proxy.h.

98 { return false; }

◆ get_current_blockchain_height()

uint64_t tests::proxy_core::get_current_blockchain_height ( )
inline

Definition at line 71 of file core_proxy.h.

71 {return 1;}

◆ get_earliest_ideal_height_for_version()

uint64_t tests::proxy_core::get_earliest_ideal_height_for_version ( uint8_t  version) const
inline

Definition at line 104 of file core_proxy.h.

104 { return 0; }

◆ get_hard_fork_version()

uint8_t tests::proxy_core::get_hard_fork_version ( uint64_t  height) const
inline

Definition at line 103 of file core_proxy.h.

103 { return 0; }

◆ get_ideal_hard_fork_version() [1/2]

uint8_t tests::proxy_core::get_ideal_hard_fork_version ( ) const
inline

Definition at line 101 of file core_proxy.h.

101 { return 0; }

◆ get_ideal_hard_fork_version() [2/2]

uint8_t tests::proxy_core::get_ideal_hard_fork_version ( uint64_t  height) const
inline

Definition at line 102 of file core_proxy.h.

102 { return 0; }

◆ get_nettype()

cryptonote::network_type tests::proxy_core::get_nettype ( ) const
inline

Definition at line 95 of file core_proxy.h.

◆ get_pool_transaction()

bool tests::proxy_core::get_pool_transaction ( const crypto::hash id,
cryptonote::blobdata tx_blob 
) const
inline

Definition at line 96 of file core_proxy.h.

96 { return false; }

◆ get_short_chain_history()

bool tests::proxy_core::get_short_chain_history ( std::list< crypto::hash > &  ids)

Definition at line 227 of file core_proxy.cpp.

227  {
228  build_short_history(ids, m_lastblk);
229  return true;
230 }

◆ get_stat_info()

bool tests::proxy_core::get_stat_info ( cryptonote::core_stat_info st_inf)
inline

Definition at line 76 of file core_proxy.h.

76 {return true;}

◆ get_target_blockchain_height()

uint64_t tests::proxy_core::get_target_blockchain_height ( ) const
inline

Definition at line 92 of file core_proxy.h.

92 { return 1; }

◆ get_test_drop_download()

bool tests::proxy_core::get_test_drop_download ( )
inline

Definition at line 88 of file core_proxy.h.

88 {return true;}

◆ get_test_drop_download_height()

bool tests::proxy_core::get_test_drop_download_height ( )
inline

Definition at line 89 of file core_proxy.h.

89 {return true;}

◆ get_transactions()

bool tests::proxy_core::get_transactions ( const std::vector< crypto::hash > &  txs_ids,
std::vector< cryptonote::transaction > &  txs,
std::vector< crypto::hash > &  missed_txs 
) const
inline

Definition at line 99 of file core_proxy.h.

99 { return false; }

◆ get_validators_list()

std::string tests::proxy_core::get_validators_list ( )
inline

Definition at line 114 of file core_proxy.h.

114 { return ""; }

◆ handle_get_objects()

Definition at line 86 of file core_proxy.h.

86 {return true;}

◆ handle_incoming_block()

bool tests::proxy_core::handle_incoming_block ( const cryptonote::blobdata block_blob,
const cryptonote::block block,
cryptonote::block_verification_context bvc,
bool  update_miner_blocktemplate = true 
)

Definition at line 201 of file core_proxy.cpp.

201  {
202  block b = AUTO_VAL_INIT(b);
203 
204  if(!parse_and_validate_block_from_blob(block_blob, b)) {
205  cerr << "Failed to parse and validate new block" << endl;
206  return false;
207  }
208 
209  crypto::hash h;
210  crypto::hash lh;
211  cout << "BLOCK" << endl << endl;
212  cout << (h = get_block_hash(b)) << endl;
213  cout << (lh = get_block_longhash(b, 0)) << endl;
214  cout << get_transaction_hash(b.miner_tx) << endl;
215  cout << ::get_object_blobsize(b.miner_tx) << endl;
216  //cout << string_tools::buff_to_hex_nodelimer(block_blob) << endl;
217  cout << obj_to_json_str(b) << endl;
218 
219  cout << endl << "ENDBLOCK" << endl << endl;
220 
221  if (!add_block(h, lh, b, block_blob))
222  return false;
223 
224  return true;
225 }
size_t get_object_blobsize(const t_object &o)
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
std::string obj_to_json_str(T &obj)
crypto::hash get_transaction_hash(const transaction &t)
#define AUTO_VAL_INIT(v)
Definition: misc_language.h:53
crypto::hash get_block_hash(uint64_t height)
POD_CLASS hash
Definition: hash.h:50
bool parse_and_validate_block_from_blob(const blobdata &b_blob, block &b, crypto::hash *block_hash)
Here is the call graph for this function:

◆ handle_incoming_tx()

bool tests::proxy_core::handle_incoming_tx ( const cryptonote::blobdata tx_blob,
cryptonote::tx_verification_context tvc,
bool  keeped_by_block,
bool  relayed,
bool  do_not_relay 
)

Definition at line 164 of file core_proxy.cpp.

164  {
165  if (!keeped_by_block)
166  return true;
167 
168  crypto::hash tx_hash = null_hash;
169  crypto::hash tx_prefix_hash = null_hash;
170  transaction tx;
171 
172  if (!parse_and_validate_tx_from_blob(tx_blob, tx, tx_hash, tx_prefix_hash)) {
173  cerr << "WRONG TRANSACTION BLOB, Failed to parse, rejected" << endl;
174  return false;
175  }
176 
177  cout << "TX " << endl << endl;
178  cout << tx_hash << endl;
179  cout << tx_prefix_hash << endl;
180  cout << tx_blob.size() << endl;
181  //cout << string_tools::buff_to_hex_nodelimer(tx_blob) << endl << endl;
182  cout << obj_to_json_str(tx) << endl;
183  cout << endl << "ENDTX" << endl;
184 
185  return true;
186 }
std::string obj_to_json_str(T &obj)
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx)
POD_CLASS hash
Definition: hash.h:50

◆ handle_incoming_txs()

bool tests::proxy_core::handle_incoming_txs ( const std::vector< cryptonote::blobdata > &  tx_blobs,
std::vector< cryptonote::tx_verification_context > &  tvc,
bool  keeped_by_block,
bool  relayed,
bool  do_not_relay 
)

Definition at line 188 of file core_proxy.cpp.

189 {
190  tvc.resize(tx_blobs.size());
191  size_t i = 0;
192  for (const auto &tx_blob: tx_blobs)
193  {
194  if (!handle_incoming_tx(tx_blob, tvc[i], keeped_by_block, relayed, do_not_relay))
195  return false;
196  ++i;
197  }
198  return true;
199 }
bool handle_incoming_tx(const cryptonote::blobdata &tx_blob, cryptonote::tx_verification_context &tvc, bool keeped_by_block, bool relayed, bool do_not_relay)
Definition: core_proxy.cpp:164

◆ have_block()

bool tests::proxy_core::have_block ( const crypto::hash id)

Definition at line 244 of file core_proxy.cpp.

244  {
245  if (m_hash2blkidx.end() == m_hash2blkidx.find(id))
246  return false;
247  return true;
248 }

◆ init()

bool tests::proxy_core::init ( const boost::program_options::variables_map &  vm)

Definition at line 237 of file core_proxy.cpp.

237  {
239  crypto::hash h = get_block_hash(m_genesis);
240  add_block(h, get_block_longhash(m_genesis, 0), m_genesis, block_to_blob(m_genesis));
241  return true;
242 }
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
bool generate_genesis_block(block &bl, std::string const &genesis_tx, uint32_t nonce)
std::string const GENESIS_TX
uint32_t const GENESIS_NONCE
crypto::hash get_block_hash(uint64_t height)
POD_CLASS hash
Definition: hash.h:50
blobdata block_to_blob(const block &b)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidatorsListValid()

bool tests::proxy_core::isValidatorsListValid ( )
inline

Definition at line 113 of file core_proxy.h.

113 { return true; }

◆ on_idle()

bool tests::proxy_core::on_idle ( )
inline

Definition at line 84 of file core_proxy.h.

84 {return true;}

◆ on_synchronized()

void tests::proxy_core::on_synchronized ( )
inline

Definition at line 69 of file core_proxy.h.

69 {}

◆ on_transaction_relayed()

virtual void tests::proxy_core::on_transaction_relayed ( const cryptonote::blobdata tx)
inlinevirtual

Definition at line 94 of file core_proxy.h.

94 {}

◆ pad_transactions()

bool tests::proxy_core::pad_transactions ( ) const
inline

Definition at line 108 of file core_proxy.h.

108 { return false; }

◆ pause_mine()

void tests::proxy_core::pause_mine ( )
inline

Definition at line 82 of file core_proxy.h.

82 {}

◆ pool_has_tx()

bool tests::proxy_core::pool_has_tx ( const crypto::hash txid) const
inline

Definition at line 97 of file core_proxy.h.

97 { return false; }

◆ prepare_handle_incoming_blocks()

bool tests::proxy_core::prepare_handle_incoming_blocks ( const std::vector< cryptonote::block_complete_entry > &  blocks_entry,
std::vector< cryptonote::block > &  blocks 
)
inline

Definition at line 90 of file core_proxy.h.

90 { return true; }

◆ prevalidate_block_hashes()

uint64_t tests::proxy_core::prevalidate_block_hashes ( uint64_t  height,
const std::vector< crypto::hash > &  hashes 
)
inline

Definition at line 107 of file core_proxy.h.

107 { return 0; }

◆ prune_blockchain()

bool tests::proxy_core::prune_blockchain ( uint32_t  pruning_seed) const
inline

Definition at line 110 of file core_proxy.h.

110 { return true; }

◆ resume_mine()

void tests::proxy_core::resume_mine ( )
inline

Definition at line 83 of file core_proxy.h.

83 {}

◆ safesyncmode()

void tests::proxy_core::safesyncmode ( const bool  )
inline

Definition at line 70 of file core_proxy.h.

70 {}

◆ set_block_cumulative_difficulty()

void tests::proxy_core::set_block_cumulative_difficulty ( uint64_t  height,
cryptonote::difficulty_type  diff 
)
inline

Definition at line 111 of file core_proxy.h.

111 {}

◆ set_target_blockchain_height()

void tests::proxy_core::set_target_blockchain_height ( uint64_t  )
inline

Definition at line 72 of file core_proxy.h.

72 {}

◆ set_validators_list()

electroneum::basic::list_update_outcome tests::proxy_core::set_validators_list ( std::string  v_list,
bool  isEmergencyUpdate = false 
)
inline

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