diff --git a/nano/core_test/active_elections.cpp b/nano/core_test/active_elections.cpp index aabdce1c40..38c599df17 100644 --- a/nano/core_test/active_elections.cpp +++ b/nano/core_test/active_elections.cpp @@ -649,14 +649,14 @@ TEST (active_elections, dropped_cleanup) nano::vectorstream stream (block_bytes); chain[0]->serialize (stream); } - ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); - ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); + ASSERT_FALSE (node.network.filter.apply (block_bytes.data (), block_bytes.size ())); + ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ())); auto election = nano::test::start_election (system, node, hash); ASSERT_NE (nullptr, election); // Not yet removed - ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); + ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ())); ASSERT_TRUE (node.vote_router.active (hash)); // Now simulate dropping the election @@ -664,7 +664,7 @@ TEST (active_elections, dropped_cleanup) node.active.erase (*chain[0]); // The filter must have been cleared - ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); + ASSERT_FALSE (node.network.filter.apply (block_bytes.data (), block_bytes.size ())); // An election was recently dropped ASSERT_EQ (1, node.stats.count (nano::stat::type::active_elections_dropped, nano::stat::detail::manual)); @@ -673,7 +673,7 @@ TEST (active_elections, dropped_cleanup) ASSERT_FALSE (node.vote_router.active (hash)); // Repeat test for a confirmed election - ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); + ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ())); election = nano::test::start_election (system, node, hash); ASSERT_NE (nullptr, election); @@ -682,7 +682,7 @@ TEST (active_elections, dropped_cleanup) node.active.erase (*chain[0]); // The filter should not have been cleared - ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ())); + ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ())); // Not dropped ASSERT_EQ (1, node.stats.count (nano::stat::type::active_elections_dropped, nano::stat::detail::manual)); @@ -825,7 +825,7 @@ TEST (active_elections, fork_filter_cleanup) ASSERT_TIMELY_EQ (5s, node1.ledger.block_count (), 2); // Block is erased from the duplicate filter - ASSERT_TIMELY (5s, node1.network.publish_filter.apply (send_block_bytes.data (), send_block_bytes.size ())); + ASSERT_TIMELY (5s, node1.network.filter.apply (send_block_bytes.data (), send_block_bytes.size ())); } /* @@ -960,7 +960,7 @@ TEST (active_elections, fork_replacement_tally) // Process correct block node_config.peering_port = system.get_available_port (); auto & node2 (*system.add_node (node_config)); - node1.network.publish_filter.clear (); + node1.network.filter.clear (); node2.network.flood_block (send_last); ASSERT_TIMELY (3s, node1.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) > 0); @@ -974,7 +974,7 @@ TEST (active_elections, fork_replacement_tally) node1.vote_processor.vote (vote, std::make_shared (node1, node1)); // ensure vote arrives before the block ASSERT_TIMELY_EQ (5s, 1, node1.vote_cache.find (send_last->hash ()).size ()); - node1.network.publish_filter.clear (); + node1.network.filter.clear (); node2.network.flood_block (send_last); ASSERT_TIMELY (5s, node1.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) > 1); diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 3ac09219d8..eb4713f946 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -735,8 +735,8 @@ TEST (network, duplicate_revert_publish) // Should be cleared when dropping due to a full block processor, as long as the message has the optional digest attached // Test network.duplicate_detection ensures that the digest is attached when deserializing messages nano::uint128_t digest; - ASSERT_FALSE (node.network.publish_filter.apply (bytes.data (), bytes.size (), &digest)); - ASSERT_TRUE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); + ASSERT_FALSE (node.network.filter.apply (bytes.data (), bytes.size (), &digest)); + ASSERT_TRUE (node.network.filter.apply (bytes.data (), bytes.size ())); auto other_node (std::make_shared (system.io_ctx, system.get_available_port (), nano::unique_path (), system.work)); other_node->start (); system.nodes.push_back (other_node); @@ -744,10 +744,10 @@ TEST (network, duplicate_revert_publish) ASSERT_NE (nullptr, channel); ASSERT_EQ (0, publish.digest); node.network.inbound (publish, channel); - ASSERT_TRUE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); + ASSERT_TRUE (node.network.filter.apply (bytes.data (), bytes.size ())); publish.digest = digest; node.network.inbound (publish, channel); - ASSERT_FALSE (node.network.publish_filter.apply (bytes.data (), bytes.size ())); + ASSERT_FALSE (node.network.filter.apply (bytes.data (), bytes.size ())); } TEST (network, duplicate_vote_detection) @@ -798,14 +798,14 @@ TEST (network, duplicate_revert_vote) // First vote should be processed tcp_channel->send (message1); ASSERT_ALWAYS_EQ (100ms, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_confirm_ack_message), 0); - ASSERT_TIMELY (5s, node1.network.publish_filter.check (bytes1.data (), bytes1.size ())); + ASSERT_TIMELY (5s, node1.network.filter.check (bytes1.data (), bytes1.size ())); // Second vote should get dropped from processor queue tcp_channel->send (message2); ASSERT_ALWAYS_EQ (100ms, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_confirm_ack_message), 0); // And the filter should not have it WAIT (500ms); // Give the node time to process the vote - ASSERT_TIMELY (5s, !node1.network.publish_filter.check (bytes2.data (), bytes2.size ())); + ASSERT_TIMELY (5s, !node1.network.filter.check (bytes2.data (), bytes2.size ())); } TEST (network, expire_duplicate_filter) @@ -832,8 +832,8 @@ TEST (network, expire_duplicate_filter) ASSERT_TIMELY_EQ (2s, node1.stats.count (nano::stat::type::filter, nano::stat::detail::duplicate_confirm_ack_message), 1); // The filter should expire the vote after some time - ASSERT_TRUE (node1.network.publish_filter.check (bytes.data (), bytes.size ())); - ASSERT_TIMELY (10s, !node1.network.publish_filter.check (bytes.data (), bytes.size ())); + ASSERT_TRUE (node1.network.filter.check (bytes.data (), bytes.size ())); + ASSERT_TIMELY (10s, !node1.network.filter.check (bytes.data (), bytes.size ())); } // The test must be completed in less than 1 second diff --git a/nano/core_test/node.cpp b/nano/core_test/node.cpp index 7a3ea364bb..7a8f1df340 100644 --- a/nano/core_test/node.cpp +++ b/nano/core_test/node.cpp @@ -2220,7 +2220,7 @@ TEST (node, vote_by_hash_republish) ASSERT_TIMELY (5s, node2.active.active (*send1)); // give block send2 to node1 and wait until the block is received and processed by node1 - node1.network.publish_filter.clear (); + node1.network.filter.clear (); node1.process_active (send2); ASSERT_TIMELY (5s, node1.active.active (*send2)); diff --git a/nano/fuzzer_test/fuzz_buffer.cpp b/nano/fuzzer_test/fuzz_buffer.cpp index 4be2240286..9f584395ae 100644 --- a/nano/fuzzer_test/fuzz_buffer.cpp +++ b/nano/fuzzer_test/fuzz_buffer.cpp @@ -68,7 +68,7 @@ void fuzz_message_parser (uint8_t const * Data, size_t Size) } fuzz_visitor visitor; - nano::message_parser parser (node0->network.publish_filter, node0->block_uniquer, node0->vote_uniquer, visitor, node0->work); + nano::message_parser parser (node0->network.filter, node0->block_uniquer, node0->vote_uniquer, visitor, node0->work); parser.deserialize_buffer (Data, Size); } diff --git a/nano/node/active_elections.cpp b/nano/node/active_elections.cpp index 7c4aadc631..814cf088ab 100644 --- a/nano/node/active_elections.cpp +++ b/nano/node/active_elections.cpp @@ -363,7 +363,7 @@ void nano::active_elections::cleanup_election (nano::unique_lock & if (!election->confirmed ()) { // Clear from publish filter - node.network.publish_filter.clear (block); + node.network.filter.clear (block); } } } diff --git a/nano/node/election.cpp b/nano/node/election.cpp index c3845fc23e..98fa9ba491 100644 --- a/nano/node/election.cpp +++ b/nano/node/election.cpp @@ -518,7 +518,7 @@ bool nano::election::publish (std::shared_ptr const & block_a) if (!replace_by_weight (lock, block_a->hash ())) { result = true; - node.network.publish_filter.clear (block_a); + node.network.filter.clear (block_a); } debug_assert (lock.owns_lock ()); } @@ -643,7 +643,7 @@ void nano::election::remove_block (nano::block_hash const & hash_a) return entry.second.hash == hash_a; }); - node.network.publish_filter.clear (existing->second); + node.network.filter.clear (existing->second); last_blocks.erase (hash_a); } } diff --git a/nano/node/message_processor.cpp b/nano/node/message_processor.cpp index cd400daa1d..f43126b4d4 100644 --- a/nano/node/message_processor.cpp +++ b/nano/node/message_processor.cpp @@ -190,7 +190,7 @@ class process_visitor : public nano::message_visitor bool added = node.block_processor.add (message.block, message.is_originator () ? nano::block_source::live_originator : nano::block_source::live, channel); if (!added) { - node.network.publish_filter.clear (message.digest); + node.network.filter.clear (message.digest); node.stats.inc (nano::stat::type::drop, nano::stat::detail::publish, nano::stat::dir::in); } } @@ -220,7 +220,7 @@ class process_visitor : public nano::message_visitor bool added = node.vote_processor.vote (message.vote, channel, message.is_rebroadcasted () ? nano::vote_source::rebroadcast : nano::vote_source::live); if (!added) { - node.network.publish_filter.clear (message.digest); + node.network.filter.clear (message.digest); node.stats.inc (nano::stat::type::drop, nano::stat::detail::confirm_ack, nano::stat::dir::in); } } diff --git a/nano/node/network.cpp b/nano/node/network.cpp index df4932aa3a..5073cf35e3 100644 --- a/nano/node/network.cpp +++ b/nano/node/network.cpp @@ -25,7 +25,7 @@ nano::network::network (nano::node & node, uint16_t port) : id{ nano::network_constants::active_network }, syn_cookies{ node.config.network.max_peers_per_ip, node.logger }, resolver{ node.io_ctx }, - publish_filter{ node.config.network.duplicate_filter_size, node.config.network.duplicate_filter_cutoff }, + filter{ node.config.network.duplicate_filter_size, node.config.network.duplicate_filter_cutoff }, tcp_channels{ node }, port{ port } { @@ -117,7 +117,7 @@ void nano::network::run_cleanup () auto const syn_cookie_cutoff = std::chrono::steady_clock::now () - node.network_params.network.syn_cookie_cutoff; syn_cookies.purge (syn_cookie_cutoff); - publish_filter.update (interval.count ()); + filter.update (interval.count ()); lock.lock (); } diff --git a/nano/node/network.hpp b/nano/node/network.hpp index bac8f5c166..e33cbd5f06 100644 --- a/nano/node/network.hpp +++ b/nano/node/network.hpp @@ -151,7 +151,7 @@ class network final nano::syn_cookies syn_cookies; boost::asio::ip::tcp::resolver resolver; nano::peer_exclusion excluded_peers; - nano::network_filter publish_filter; + nano::network_filter filter; nano::transport::tcp_channels tcp_channels; std::atomic port{ 0 }; diff --git a/nano/node/transport/inproc.cpp b/nano/node/transport/inproc.cpp index e1c8383f09..c1cf7a5b9f 100644 --- a/nano/node/transport/inproc.cpp +++ b/nano/node/transport/inproc.cpp @@ -30,7 +30,7 @@ void nano::transport::inproc::channel::send_buffer (nano::shared_const_buffer co callback_a (boost::system::errc::make_error_code (boost::system::errc::success), size_a); }; - auto const message_deserializer = std::make_shared (node.network_params.network, node.network.publish_filter, node.block_uniquer, node.vote_uniquer, buffer_read_fn); + auto const message_deserializer = std::make_shared (node.network_params.network, node.network.filter, node.block_uniquer, node.vote_uniquer, buffer_read_fn); message_deserializer->read ( [this] (boost::system::error_code ec_a, std::unique_ptr message_a) { if (ec_a || !message_a) diff --git a/nano/node/transport/tcp_server.cpp b/nano/node/transport/tcp_server.cpp index f7075faa38..a4e59e6748 100644 --- a/nano/node/transport/tcp_server.cpp +++ b/nano/node/transport/tcp_server.cpp @@ -17,7 +17,7 @@ nano::transport::tcp_server::tcp_server (std::shared_ptr (node_a->network_params.network, node_a->network.publish_filter, node_a->block_uniquer, node_a->vote_uniquer, + std::make_shared (node_a->network_params.network, node_a->network.filter, node_a->block_uniquer, node_a->vote_uniquer, [socket_l = socket] (std::shared_ptr> const & data_a, size_t size_a, std::function callback_a) { debug_assert (socket_l != nullptr); socket_l->read_impl (data_a, size_a, callback_a);