diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 20 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 5 | ||||
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 7 | ||||
-rw-r--r-- | src/daemon/command_parser_executor.h | 2 | ||||
-rw-r--r-- | src/daemon/command_server.cpp | 5 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 28 | ||||
-rw-r--r-- | src/daemon/rpc_command_executor.h | 2 |
7 files changed, 60 insertions, 9 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 98c53890e..cfe3b5441 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -60,6 +60,8 @@ DISABLE_VS_WARNINGS(4355) #define MERROR_VER(x) MCERROR("verify", x) +#define BAD_SEMANTICS_TXES_MAX_SIZE 100 + namespace cryptonote { @@ -496,11 +498,14 @@ namespace cryptonote } //std::cout << "!"<< tx.vin.size() << std::endl; - if (bad_semantics_txes.find(tx_hash) != bad_semantics_txes.end()) + for (int idx = 0; idx < 2; ++idx) { - LOG_PRINT_L1("Transaction already seen with bad semantics, rejected"); - tvc.m_verifivation_failed = true; - return false; + if (bad_semantics_txes[idx].find(tx_hash) != bad_semantics_txes[idx].end()) + { + LOG_PRINT_L1("Transaction already seen with bad semantics, rejected"); + tvc.m_verifivation_failed = true; + return false; + } } uint8_t version = m_blockchain_storage.get_current_hard_fork_version(); @@ -551,8 +556,13 @@ namespace cryptonote if(!check_tx_semantic(tx, keeped_by_block)) { LOG_PRINT_L1("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " semantic, rejected"); - bad_semantics_txes.insert(tx_hash); tvc.m_verifivation_failed = true; + bad_semantics_txes[0].insert(tx_hash); + if (bad_semantics_txes[0].size() >= BAD_SEMANTICS_TXES_MAX_SIZE) + { + std::swap(bad_semantics_txes[0], bad_semantics_txes[1]); + bad_semantics_txes[0].clear(); + } return false; } diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 114e8393e..7323bef29 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -818,7 +818,6 @@ namespace cryptonote epee::math_helper::once_a_time_seconds<60*2, false> m_txpool_auto_relayer; //!< interval for checking re-relaying txpool transactions epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions - friend class tx_validate_inputs; std::atomic<bool> m_starter_message_showed; //!< has the "daemon will sync now" message been shown? uint64_t m_target_blockchain_height; //!< blockchain height target @@ -833,13 +832,11 @@ namespace cryptonote std::atomic_flag m_checkpoints_updating; //!< set if checkpoints are currently updating to avoid multiple threads attempting to update at once - boost::interprocess::file_lock db_lock; //!< a lock object for a file lock in the db directory - size_t block_sync_size; time_t start_time; - std::unordered_set<crypto::hash> bad_semantics_txes; + std::unordered_set<crypto::hash> bad_semantics_txes[2]; enum { UPDATES_DISABLED, diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 2bb4196af..8daaac611 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -51,6 +51,13 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>& return m_executor.print_peer_list(); } +bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args) +{ + if (!args.empty()) return false; + + return m_executor.print_peer_list_stats(); +} + bool t_command_parser_executor::save_blockchain(const std::vector<std::string>& args) { if (!args.empty()) return false; diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h index 3ea2b923a..37f431974 100644 --- a/src/daemon/command_parser_executor.h +++ b/src/daemon/command_parser_executor.h @@ -59,6 +59,8 @@ public: bool print_peer_list(const std::vector<std::string>& args); + bool print_peer_list_stats(const std::vector<std::string>& args); + bool save_blockchain(const std::vector<std::string>& args); bool show_hash_rate(const std::vector<std::string>& args); diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp index 90142f2fb..4a063268f 100644 --- a/src/daemon/command_server.cpp +++ b/src/daemon/command_server.cpp @@ -69,6 +69,11 @@ t_command_server::t_command_server( , "Print peer list" ); m_command_lookup.set_handler( + "print_pl_stats" + , std::bind(&t_command_parser_executor::print_peer_list_stats, &m_parser, p::_1) + , "Print peer list stats" + ); + m_command_lookup.set_handler( "print_cn" , std::bind(&t_command_parser_executor::print_connections, &m_parser, p::_1) , "Print connections" diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index a3d9eb52a..b33736839 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -162,6 +162,34 @@ bool t_rpc_command_executor::print_peer_list() { return true; } +bool t_rpc_command_executor::print_peer_list_stats() { + cryptonote::COMMAND_RPC_GET_PEER_LIST::request req; + cryptonote::COMMAND_RPC_GET_PEER_LIST::response res; + + std::string failure_message = "Couldn't retrieve peer list"; + if (m_is_rpc) + { + if (!m_rpc_client->rpc_request(req, res, "/get_peer_list", failure_message.c_str())) + { + return false; + } + } + else + { + if (!m_rpc_server->on_get_peer_list(req, res) || res.status != CORE_RPC_STATUS_OK) + { + tools::fail_msg_writer() << failure_message; + return false; + } + } + + tools::msg_writer() + << "White list size: " << res.white_list.size() << "/" << P2P_LOCAL_WHITE_PEERLIST_LIMIT << " (" << res.white_list.size() * 100.0 / P2P_LOCAL_WHITE_PEERLIST_LIMIT << "%)" << std::endl + << "Gray list size: " << res.gray_list.size() << "/" << P2P_LOCAL_GRAY_PEERLIST_LIMIT << " (" << res.gray_list.size() * 100.0 / P2P_LOCAL_GRAY_PEERLIST_LIMIT << "%)"; + + return true; +} + bool t_rpc_command_executor::save_blockchain() { cryptonote::COMMAND_RPC_SAVE_BC::request req; cryptonote::COMMAND_RPC_SAVE_BC::response res; diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h index 39db75a80..eb95101ce 100644 --- a/src/daemon/rpc_command_executor.h +++ b/src/daemon/rpc_command_executor.h @@ -72,6 +72,8 @@ public: bool print_peer_list(); + bool print_peer_list_stats(); + bool save_blockchain(); bool show_hash_rate(); |