41 #include <boost/program_options.hpp> 46 #include "p2p/net_node.inl" 49 #include "cryptonote_protocol/cryptonote_protocol_handler.inl" 57 namespace po = boost::program_options;
66 int main(
int argc,
char* argv[])
70 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
83 po::options_description desc(
"Allowed options");
97 MGINFO(
"Module folder: " << argv[0]);
98 MGINFO(
"Node starting ...");
113 MGINFO(
"Initializing p2p server...");
114 bool res = p2psrv.init(vm);
116 MGINFO(
"P2p server initialized OK");
118 MGINFO(
"Initializing cryptonote protocol...");
121 MGINFO(
"Cryptonote protocol initialized OK");
124 MGINFO(
"Initializing proxy core...");
127 MGINFO(
"Core initialized OK");
129 MGINFO(
"Starting p2p net loop...");
131 MGINFO(
"p2p net loop stopped");
134 MGINFO(
"Deinitializing core...");
136 MGINFO(
"Deinitializing cryptonote_protocol...");
138 MGINFO(
"Deinitializing p2p...");
165 if (!keeped_by_block)
173 cerr <<
"WRONG TRANSACTION BLOB, Failed to parse, rejected" << endl;
177 cout <<
"TX " << endl << endl;
178 cout << tx_hash << endl;
179 cout << tx_prefix_hash << endl;
180 cout << tx_blob.size() << endl;
183 cout << endl <<
"ENDTX" << endl;
190 tvc.resize(tx_blobs.size());
192 for (
const auto &tx_blob: tx_blobs)
194 if (!handle_incoming_tx(tx_blob, tvc[i], keeped_by_block, relayed, do_not_relay))
205 cerr <<
"Failed to parse and validate new block" << endl;
211 cout <<
"BLOCK" << endl << endl;
219 cout << endl <<
"ENDBLOCK" << endl << endl;
221 if (!add_block(h, lh, b, block_blob))
228 build_short_history(ids, m_lastblk);
245 if (m_hash2blkidx.end() == m_hash2blkidx.find(
id))
250 void tests::proxy_core::build_short_history(std::list<crypto::hash> &m_history,
const crypto::hash &m_start) {
268 if (crypto::null_hash != _blk.
prev_id) {
269 std::unordered_map<crypto::hash, tests::block_index>::const_iterator cit = m_hash2blkidx.find(_blk.
prev_id);
270 if (m_hash2blkidx.end() == cit) {
271 cerr <<
"ERROR: can't find previous block with id \"" << _blk.
prev_id <<
"\"" << endl;
275 height = cit->second.height + 1;
278 m_known_block_list.push_back(_id);
280 block_index bi(
height, _id, _longhash, _blk, _blob, txes);
281 m_hash2blkidx.insert(std::make_pair(_id, bi));
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
void get_blockchain_top(uint64_t &height, crypto::hash &top_id)
void set_p2p_endpoint(nodetool::i_p2p_endpoint< connection_context > *p2p)
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
size_t get_object_blobsize(const t_object &o)
bool get_short_chain_history(std::list< crypto::hash > &ids)
std::string mlog_get_default_log_path(const char *default_filename)
void mlog_configure(const std::string &filename_base, bool console, const std::size_t max_log_file_size=MAX_LOG_FILE_SIZE, const std::size_t max_log_files=MAX_LOG_FILES)
bool init(const boost::program_options::variables_map &vm)
Holds cryptonote related classes and helpers.
bool get_block_longhash(const block &b, crypto::hash &res, uint64_t height)
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 generate_genesis_block(block &bl, std::string const &genesis_tx, uint32_t nonce)
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
bool have_block(const crypto::hash &id)
std::string const GENESIS_TX
std::string obj_to_json_str(T &obj)
unsigned __int64 uint64_t
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
BOOST_CLASS_VERSION(nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< tests::proxy_core > >, 1)
bool parse_and_validate_tx_from_blob(const blobdata &tx_blob, transaction &tx)
This is the orginal cryptonote protocol network-events handler, modified by us.
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
bool handle_incoming_block(const cryptonote::blobdata &block_blob, const cryptonote::block *block, cryptonote::block_verification_context &bvc, bool update_miner_blocktemplate=true)
crypto::hash get_transaction_hash(const transaction &t)
boost::program_options::basic_parsed_options< charT > parse_command_line(int argc, const charT *const argv[], const boost::program_options::options_description &desc, bool allow_unregistered=false)
uint32_t const GENESIS_NONCE
bool init(const boost::program_options::variables_map &vm)
crypto::hash get_block_hash(uint64_t height)
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)
blobdata block_to_blob(const block &b)
#define CATCH_ENTRY_L0(lacation, return_val)
void mlog_set_log_level(int level)
int main(int argc, char *argv[])
bool parse_and_validate_block_from_blob(const blobdata &b_blob, block &b, crypto::hash *block_hash)