From 690ce560b0f7eb806573d1f96d19b5e6c7d3673e Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Mar 2022 17:49:11 -0600 Subject: Boring Old Deletes Here lies dozens of unused files. This commit is ONLY file deletions except for the removing of a couple of #includes and removing filenames from CmakeLists where appropriate. --- src/p2p/stdafx.h | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 src/p2p/stdafx.h (limited to 'src/p2p') diff --git a/src/p2p/stdafx.h b/src/p2p/stdafx.h deleted file mode 100644 index 27157c8cd..000000000 --- a/src/p2p/stdafx.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2014-2022, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once - -#include "targetver.h" - - -#if !defined(__GNUC__) -#define _CRTDBG_MAP_ALLOC -#include -#include -#endif - - - -#include - - -#define BOOST_FILESYSTEM_VERSION 3 -#define ENABLE_RELEASE_LOGGING -#include "log_opt_defs.h" -#include "misc_log_ex.h" - - - -- cgit v1.2.3 From 12b1b74d322f9933bb5d2ccbccd2566ee44cd3fc Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Mar 2022 18:27:28 -0600 Subject: Trimming Fat Remove unused include statements or unused definitions. --- src/p2p/net_node.inl | 1 - 1 file changed, 1 deletion(-) (limited to 'src/p2p') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 5c61ede3f..a3bc3bf24 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -55,7 +55,6 @@ #include "math_helper.h" #include "misc_log_ex.h" #include "p2p_protocol_defs.h" -#include "net/local_ip.h" #include "crypto/crypto.h" #include "storages/levin_abstract_invoke2.h" #include "cryptonote_core/cryptonote_core.h" -- cgit v1.2.3 From 40f02f9d739a207f124bf07c590b9e7c94244eaf Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Mar 2022 18:34:39 -0600 Subject: Add Include statements --- src/p2p/p2p_protocol_defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/p2p') diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index fbeef6e62..8b9cd0f09 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -30,6 +30,7 @@ #pragma once +#include #include #include #include "serialization/keyvalue_serialization.h" -- cgit v1.2.3 From 1f25aa27c5cf83afd8e332bd5fe84c88c3dd7ffd Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Mon, 7 Mar 2022 20:49:19 -0600 Subject: Factor out move_it_backward from misc_language.h Relevant commit from old PR: 330df2952cb2863a591158b984c0fb7f652887ac --- src/p2p/net_peerlist.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/p2p') diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h index 2cb85d270..8a56bb378 100644 --- a/src/p2p/net_peerlist.h +++ b/src/p2p/net_peerlist.h @@ -31,6 +31,7 @@ #pragma once #include +#include #include #include #include @@ -46,7 +47,6 @@ #include "crypto/crypto.h" #include "cryptonote_config.h" #include "net/enums.h" -#include "net/local_ip.h" #include "p2p_protocol_defs.h" #include "syncobj.h" @@ -184,6 +184,7 @@ namespace nodetool private: void trim_white_peerlist(); void trim_gray_peerlist(); + static peerlist_entry get_nth_latest_peer(peers_indexed& peerlist, size_t n); friend class boost::serialization::access; epee::critical_section m_peerlist_lock; @@ -214,6 +215,16 @@ namespace nodetool } } //-------------------------------------------------------------------------------------------------- + inline + peerlist_entry peerlist_manager::get_nth_latest_peer(peers_indexed& peerlist, const size_t n) + { + // Is not thread-safe nor does it check bounds. Do this before calling. Indexing starts at 0. + peers_indexed::index::type& by_time_index = peerlist.get(); + auto by_time_it = --by_time_index.end(); + std::advance(by_time_it, -((long long) n)); + return *by_time_it; + } + //-------------------------------------------------------------------------------------------------- inline bool peerlist_manager::merge_peerlist(const std::vector& outer_bs, const std::function &f) { @@ -235,8 +246,7 @@ namespace nodetool if(i >= m_peers_white.size()) return false; - peers_indexed::index::type& by_time_index = m_peers_white.get(); - p = *epee::misc_utils::move_it_backward(--by_time_index.end(), i); + p = peerlist_manager::get_nth_latest_peer(m_peers_white, i); return true; } //-------------------------------------------------------------------------------------------------- @@ -247,8 +257,7 @@ namespace nodetool if(i >= m_peers_gray.size()) return false; - peers_indexed::index::type& by_time_index = m_peers_gray.get(); - p = *epee::misc_utils::move_it_backward(--by_time_index.end(), i); + p = peerlist_manager::get_nth_latest_peer(m_peers_gray, i); return true; } //-------------------------------------------------------------------------------------------------- @@ -437,9 +446,7 @@ namespace nodetool } size_t random_index = crypto::rand_idx(m_peers_gray.size()); - - peers_indexed::index::type& by_time_index = m_peers_gray.get(); - pe = *epee::misc_utils::move_it_backward(--by_time_index.end(), random_index); + pe = peerlist_manager::get_nth_latest_peer(m_peers_gray, random_index); return true; -- cgit v1.2.3 From 11371425f562f7202aff74004776489b93973af8 Mon Sep 17 00:00:00 2001 From: Jeffrey Date: Thu, 10 Mar 2022 10:46:21 -0600 Subject: "Change C-cast to static_cast in net_peerlist.h" Thanks @mj-xmr: https://github.com/monero-project/monero/pull/8211#discussion_r823870855 --- src/p2p/net_peerlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/p2p') diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h index 8a56bb378..dc480462d 100644 --- a/src/p2p/net_peerlist.h +++ b/src/p2p/net_peerlist.h @@ -221,7 +221,7 @@ namespace nodetool // Is not thread-safe nor does it check bounds. Do this before calling. Indexing starts at 0. peers_indexed::index::type& by_time_index = peerlist.get(); auto by_time_it = --by_time_index.end(); - std::advance(by_time_it, -((long long) n)); + std::advance(by_time_it, -static_cast(n)); return *by_time_it; } //-------------------------------------------------------------------------------------------------- -- cgit v1.2.3