From 25d8264c95eaf98a66df32addb0bf32d795a35bd Mon Sep 17 00:00:00 2001 From: tryphe Date: Wed, 8 May 2019 04:34:01 -0400 Subject: [PATCH 1/2] p2p: add MAX_FEELER_CONNECTIONS constant --- src/init.cpp | 2 +- src/net.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 221cab15f8..18a1ccf7b8 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1879,7 +1879,7 @@ bool AppInitMain(NodeContext& node) connOptions.m_max_outbound_full_relay = std::min(MAX_OUTBOUND_FULL_RELAY_CONNECTIONS, connOptions.nMaxConnections); connOptions.m_max_outbound_block_relay = std::min(MAX_BLOCKS_ONLY_CONNECTIONS, connOptions.nMaxConnections-connOptions.m_max_outbound_full_relay); connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS; - connOptions.nMaxFeeler = 1; + connOptions.nMaxFeeler = MAX_FEELER_CONNECTIONS; connOptions.nBestHeight = chain_active_height; connOptions.uiInterface = &uiInterface; connOptions.m_banman = node.banman.get(); diff --git a/src/net.h b/src/net.h index 35d442e61f..66aac6f084 100644 --- a/src/net.h +++ b/src/net.h @@ -62,6 +62,8 @@ static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8; static const int MAX_ADDNODE_CONNECTIONS = 8; /** Maximum number of block-relay-only outgoing connections */ static const int MAX_BLOCKS_ONLY_CONNECTIONS = 2; +/** Maximum number of feeler connections */ +static const int MAX_FEELER_CONNECTIONS = 1; /** -listen default */ static const bool DEFAULT_LISTEN = true; /** -upnp default */ From e3047edfb63c3d098cb56ba9f9a1e7e0a795d552 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 12 May 2020 17:29:36 +0800 Subject: [PATCH 2/2] test: use p2p constants in denial of service tests --- src/test/denialofservice_tests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index 6314c1a42f..75b38670c9 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -151,11 +151,11 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management) auto peerLogic = MakeUnique(connman.get(), nullptr, *m_node.scheduler, *m_node.mempool); const Consensus::Params& consensusParams = Params().GetConsensus(); - constexpr int max_outbound_full_relay = 8; + constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS; CConnman::Options options; - options.nMaxConnections = 125; + options.nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS; options.m_max_outbound_full_relay = max_outbound_full_relay; - options.nMaxFeeler = 1; + options.nMaxFeeler = MAX_FEELER_CONNECTIONS; connman->Init(options); std::vector vNodes;