Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename blockprocessor to block_processor for consistency #4812

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nano/core_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_executable(
backlog.cpp
block.cpp
block_store.cpp
blockprocessor.cpp
block_processor.cpp
bootstrap.cpp
bootstrap_server.cpp
bucketing.cpp
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion nano/core_test/confirming_set.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/logging.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/confirming_set.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5854,7 +5854,7 @@ TEST (ledger_transaction, write_wait_order)
WAIT (250ms); // Allow thread to start

auto fut2 = std::async (std::launch::async, [&ctx, &acquired2, &latch2] {
auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::blockprocessor);
auto tx = ctx.ledger ().tx_begin_write (nano::store::writer::block_processor);
acquired2 = true;
latch2.wait (); // Wait for the signal to drop tx
});
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2404,7 +2404,7 @@ TEST (node, block_processor_reject_state)
send1->signature.bytes[0] ^= 1;
ASSERT_FALSE (node.block_or_pruned_exists (send1->hash ()));
node.process_active (send1);
ASSERT_TIMELY_EQ (5s, 1, node.stats.count (nano::stat::type::blockprocessor_result, nano::stat::detail::bad_signature));
ASSERT_TIMELY_EQ (5s, 1, node.stats.count (nano::stat::type::block_processor_result, nano::stat::detail::bad_signature));
ASSERT_FALSE (node.block_or_pruned_exists (send1->hash ()));
auto send2 = builder.make_block ()
.account (nano::dev::genesis_key.pub)
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/toml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ TEST (toml_config, log_config_no_defaults)

[log.levels]
active_elections = "trace"
blockprocessor = "trace"
block_processor = "trace"
)toml";

nano::tomlconfig toml;
Expand Down
4 changes: 2 additions & 2 deletions nano/lib/logging_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ enum class type
tls,
active_elections,
election,
blockprocessor,
block_processor,
network,
message,
channel,
Expand Down Expand Up @@ -122,7 +122,7 @@ enum class detail
election_expired,
broadcast_vote,

// blockprocessor
// block_processor
block_processed,

// vote_processor
Expand Down
10 changes: 5 additions & 5 deletions nano/lib/stats_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ enum class type
vote_cache,
vote_cache_processor,
hinting,
blockprocessor,
blockprocessor_source,
blockprocessor_result,
blockprocessor_overfill,
block_processor,
block_processor_source,
block_processor_result,
block_processor_overfill,
bootstrap,
bootstrap_verify,
bootstrap_verify_blocks,
Expand Down Expand Up @@ -206,7 +206,7 @@ enum class detail
representative_mismatch,
block_position,

// blockprocessor
// block_processor
process_blocking,
process_blocking_timeout,
force,
Expand Down
4 changes: 2 additions & 2 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ add_library(
backlog_scan.cpp
bandwidth_limiter.hpp
bandwidth_limiter.cpp
blockprocessor.hpp
blockprocessor.cpp
block_processor.hpp
block_processor.cpp
bucketing.hpp
bucketing.cpp
bounded_backlog.hpp
Expand Down
46 changes: 23 additions & 23 deletions nano/node/blockprocessor.cpp → nano/node/block_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <nano/lib/threading.hpp>
#include <nano/lib/timer.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/node.hpp>
#include <nano/node/unchecked_map.hpp>
Expand Down Expand Up @@ -111,12 +111,12 @@ bool nano::block_processor::add (std::shared_ptr<nano::block> const & block, blo
{
if (network_params.work.validate_entry (*block)) // true => error
{
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::insufficient_work);
stats.inc (nano::stat::type::block_processor, nano::stat::detail::insufficient_work);
return false; // Not added
}

stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::process);
logger.debug (nano::log::type::blockprocessor, "Processing block (async): {} (source: {} {})",
stats.inc (nano::stat::type::block_processor, nano::stat::detail::process);
logger.debug (nano::log::type::block_processor, "Processing block (async): {} (source: {} {})",
block->hash ().to_string (),
to_string (source),
channel ? channel->to_string () : "<unknown>"); // TODO: Lazy eval
Expand All @@ -126,8 +126,8 @@ bool nano::block_processor::add (std::shared_ptr<nano::block> const & block, blo

std::optional<nano::block_status> nano::block_processor::add_blocking (std::shared_ptr<nano::block> const & block, block_source const source)
{
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::process_blocking);
logger.debug (nano::log::type::blockprocessor, "Processing block (blocking): {} (source: {})", block->hash ().to_string (), to_string (source));
stats.inc (nano::stat::type::block_processor, nano::stat::detail::process_blocking);
logger.debug (nano::log::type::block_processor, "Processing block (blocking): {} (source: {})", block->hash ().to_string (), to_string (source));

context ctx{ block, source };
auto future = ctx.get_future ();
Expand All @@ -140,17 +140,17 @@ std::optional<nano::block_status> nano::block_processor::add_blocking (std::shar
}
catch (std::future_error const &)
{
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::process_blocking_timeout);
logger.error (nano::log::type::blockprocessor, "Block dropped when processing: {}", block->hash ().to_string ());
stats.inc (nano::stat::type::block_processor, nano::stat::detail::process_blocking_timeout);
logger.error (nano::log::type::block_processor, "Block dropped when processing: {}", block->hash ().to_string ());
}

return std::nullopt;
}

void nano::block_processor::force (std::shared_ptr<nano::block> const & block_a)
{
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::force);
logger.debug (nano::log::type::blockprocessor, "Forcing block: {}", block_a->hash ().to_string ());
stats.inc (nano::stat::type::block_processor, nano::stat::detail::force);
logger.debug (nano::log::type::block_processor, "Forcing block: {}", block_a->hash ().to_string ());

add_impl (context{ block_a, block_source::forced });
}
Expand All @@ -169,8 +169,8 @@ bool nano::block_processor::add_impl (context ctx, std::shared_ptr<nano::transpo
}
else
{
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::overfill);
stats.inc (nano::stat::type::blockprocessor_overfill, to_stat_detail (source));
stats.inc (nano::stat::type::block_processor, nano::stat::detail::overfill);
stats.inc (nano::stat::type::block_processor_overfill, to_stat_detail (source));
}
return added;
}
Expand All @@ -183,18 +183,18 @@ void nano::block_processor::rollback_competitor (secure::write_transaction const
if (successor != nullptr && successor->hash () != hash)
{
// Replace our block with the winner and roll back any dependent blocks
logger.debug (nano::log::type::blockprocessor, "Rolling back: {} and replacing with: {}", successor->hash ().to_string (), hash.to_string ());
logger.debug (nano::log::type::block_processor, "Rolling back: {} and replacing with: {}", successor->hash ().to_string (), hash.to_string ());

std::deque<std::shared_ptr<nano::block>> rollback_list;
if (ledger.rollback (transaction, successor->hash (), rollback_list))
{
stats.inc (nano::stat::type::ledger, nano::stat::detail::rollback_failed);
logger.error (nano::log::type::blockprocessor, "Failed to roll back: {} because it or a successor was confirmed", successor->hash ().to_string ());
logger.error (nano::log::type::block_processor, "Failed to roll back: {} because it or a successor was confirmed", successor->hash ().to_string ());
}
else
{
stats.inc (nano::stat::type::ledger, nano::stat::detail::rollback);
logger.debug (nano::log::type::blockprocessor, "Blocks rolled back: {}", rollback_list.size ());
logger.debug (nano::log::type::block_processor, "Blocks rolled back: {}", rollback_list.size ());
}

// Notify observers of the rolled back blocks on a background thread while not holding the ledger write lock
Expand All @@ -215,7 +215,7 @@ void nano::block_processor::run ()
// It's possible that ledger processing happens faster than the notifications can be processed by other components, cooldown here
while (workers.queued_tasks () >= config.max_queued_notifications)
{
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::cooldown);
stats.inc (nano::stat::type::block_processor, nano::stat::detail::cooldown);
condition.wait_for (lock, 100ms, [this] { return stopped; });
if (stopped)
{
Expand All @@ -225,7 +225,7 @@ void nano::block_processor::run ()

if (log_interval.elapsed (15s))
{
logger.info (nano::log::type::blockprocessor, "{} blocks (+ {} forced) in processing queue",
logger.info (nano::log::type::block_processor, "{} blocks (+ {} forced) in processing queue",
queue.size (),
queue.size ({ nano::block_source::forced }));
}
Expand All @@ -236,7 +236,7 @@ void nano::block_processor::run ()

// Queue notifications to be dispatched in the background
workers.post ([this, processed = std::move (processed)] () mutable {
stats.inc (nano::stat::type::blockprocessor, nano::stat::detail::notify);
stats.inc (nano::stat::type::block_processor, nano::stat::detail::notify);
// Set results for futures when not holding the lock
for (auto & [result, context] : processed)
{
Expand Down Expand Up @@ -298,7 +298,7 @@ auto nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock

lock.unlock ();

auto transaction = ledger.tx_begin_write (nano::store::writer::blockprocessor);
auto transaction = ledger.tx_begin_write (nano::store::writer::block_processor);

nano::timer<std::chrono::milliseconds> timer;
timer.start ();
Expand Down Expand Up @@ -329,7 +329,7 @@ auto nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock

if (number_of_blocks_processed != 0 && timer.stop () > std::chrono::milliseconds (100))
{
logger.debug (nano::log::type::blockprocessor, "Processed {} blocks ({} forced) in {} {}", number_of_blocks_processed, number_of_forced_processed, timer.value ().count (), timer.unit ());
logger.debug (nano::log::type::block_processor, "Processed {} blocks ({} forced) in {} {}", number_of_blocks_processed, number_of_forced_processed, timer.value ().count (), timer.unit ());
}

return processed;
Expand All @@ -341,10 +341,10 @@ nano::block_status nano::block_processor::process_one (secure::write_transaction
auto const hash = block->hash ();
nano::block_status result = ledger.process (transaction_a, block);

stats.inc (nano::stat::type::blockprocessor_result, to_stat_detail (result));
stats.inc (nano::stat::type::blockprocessor_source, to_stat_detail (context.source));
stats.inc (nano::stat::type::block_processor_result, to_stat_detail (result));
stats.inc (nano::stat::type::block_processor_source, to_stat_detail (context.source));

logger.trace (nano::log::type::blockprocessor, nano::log::detail::block_processed,
logger.trace (nano::log::type::block_processor, nano::log::detail::block_processed,
nano::log::arg{ "result", result },
nano::log::arg{ "source", context.source },
nano::log::arg{ "arrival", nano::log::microseconds (context.arrival) },
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions nano/node/bootstrap/bootstrap_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <nano/lib/enum_util.hpp>
#include <nano/lib/stats_enums.hpp>
#include <nano/lib/thread_roles.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/bootstrap/bootstrap_service.hpp>
#include <nano/node/bootstrap/crawlers.hpp>
#include <nano/node/network.hpp>
Expand Down Expand Up @@ -342,7 +342,7 @@ void nano::bootstrap_service::wait (std::function<bool ()> const & predicate) co
}
}

void nano::bootstrap_service::wait_blockprocessor () const
void nano::bootstrap_service::wait_block_processor () const
{
wait ([this] () {
return block_processor.size (nano::block_source::bootstrap) < config.block_processor_threshold;
Expand Down Expand Up @@ -569,7 +569,7 @@ bool nano::bootstrap_service::request_frontiers (nano::account start, std::share

void nano::bootstrap_service::run_one_priority ()
{
wait_blockprocessor ();
wait_block_processor ();
auto channel = wait_channel ();
if (!channel)
{
Expand Down Expand Up @@ -611,7 +611,7 @@ void nano::bootstrap_service::run_priorities ()

void nano::bootstrap_service::run_one_database (bool should_throttle)
{
wait_blockprocessor ();
wait_block_processor ();
auto channel = wait_channel ();
if (!channel)
{
Expand Down Expand Up @@ -641,7 +641,7 @@ void nano::bootstrap_service::run_database ()

void nano::bootstrap_service::run_one_dependency ()
{
// No need to wait for blockprocessor, as we are not processing blocks
// No need to wait for block_processor, as we are not processing blocks
auto channel = wait_channel ();
if (!channel)
{
Expand Down Expand Up @@ -669,7 +669,7 @@ void nano::bootstrap_service::run_dependencies ()

void nano::bootstrap_service::run_one_frontier ()
{
// No need to wait for blockprocessor, as we are not processing blocks
// No need to wait for block_processor, as we are not processing blocks
wait ([this] () {
return !accounts.priority_half_full ();
});
Expand Down
4 changes: 2 additions & 2 deletions nano/node/bootstrap/bootstrap_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class bootstrap_service
/* Waits for a condition to be satisfied with incremental backoff */
void wait (std::function<bool ()> const & predicate) const;

/* Ensure there is enough space in blockprocessor for queuing new blocks */
void wait_blockprocessor () const;
/* Ensure there is enough space in block_processor for queuing new blocks */
void wait_block_processor () const;
/* Waits for a channel that is not full */
std::shared_ptr<nano::transport::channel> wait_channel ();
/* Waits until a suitable account outside of cooldown period is available */
Expand Down
2 changes: 1 addition & 1 deletion nano/node/bounded_backlog.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/thread_roles.hpp>
#include <nano/node/backlog_scan.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/bounded_backlog.hpp>
#include <nano/node/confirming_set.hpp>
#include <nano/node/node.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/node/confirming_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <nano/lib/logging.hpp>
#include <nano/lib/stats.hpp>
#include <nano/lib/thread_roles.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/confirming_set.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/secure/ledger_set_any.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/node/local_block_broadcaster.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/threading.hpp>
#include <nano/lib/utility.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/confirming_set.hpp>
#include <nano/node/local_block_broadcaster.hpp>
#include <nano/node/network.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/node/local_block_broadcaster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <nano/lib/locks.hpp>
#include <nano/lib/processing_queue.hpp>
#include <nano/lib/rate_limiting.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/fwd.hpp>
#include <nano/secure/common.hpp>

Expand Down
2 changes: 1 addition & 1 deletion nano/node/nodeconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <nano/lib/stats.hpp>
#include <nano/node/active_elections.hpp>
#include <nano/node/backlog_scan.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/bootstrap/bootstrap_config.hpp>
#include <nano/node/bootstrap/bootstrap_server.hpp>
#include <nano/node/bounded_backlog.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/node/process_live_dispatcher.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/block_processor.hpp>
#include <nano/node/process_live_dispatcher.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/node/vote_cache.hpp>
Expand Down
2 changes: 1 addition & 1 deletion nano/store/write_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum class writer
{
generic,
node,
blockprocessor,
block_processor,
confirmation_height,
pruning,
voting_final,
Expand Down
Loading