Skip to content

Commit

Permalink
db: fix clang tidy after PR 2290 (#2310)
Browse files Browse the repository at this point in the history
  • Loading branch information
canepat authored Sep 5, 2024
1 parent a5f3da8 commit 026b635
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/dev/snapshots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ void merge(const SnapSettings& settings) {
void sync(const SnapSettings& settings) {
class NoopStageSchedulerAdapter : public stagedsync::StageScheduler {
public:
explicit NoopStageSchedulerAdapter() {}
explicit NoopStageSchedulerAdapter() = default;
~NoopStageSchedulerAdapter() override = default;
Task<void> schedule(std::function<void(db::RWTxn&)> /*callback*/) override {
co_return;
Expand All @@ -828,7 +828,7 @@ void sync(const SnapSettings& settings) {
auto chaindata_env = db::open_env(chaindata_env_config);
test_util::TaskRunner runner;
NoopStageSchedulerAdapter stage_scheduler;
db::SnapshotSync snapshot_sync{settings, kMainnetConfig.chain_id, chaindata_env, tmp_dir.path(), stage_scheduler};
db::SnapshotSync snapshot_sync{settings, kMainnetConfig.chain_id, chaindata_env, tmp_dir.path(), stage_scheduler}; // NOLINT(cppcoreguidelines-slicing)
runner.run(snapshot_sync.download_snapshots());
std::chrono::duration elapsed{std::chrono::steady_clock::now() - start};

Expand Down
11 changes: 5 additions & 6 deletions silkworm/db/snapshot_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include <atomic>
#include <exception>
#include <latch>
#include <stdexcept>
#include <utility>

#include <boost/asio/this_coro.hpp>
#include <gsl/util>
Expand All @@ -29,7 +29,6 @@
#include <silkworm/db/blocks/headers/header_snapshot.hpp>
#include <silkworm/db/mdbx/etl_mdbx_collector.hpp>
#include <silkworm/db/snapshot_bundle_factory_impl.hpp>
#include <silkworm/db/snapshots/index_builder.hpp>
#include <silkworm/db/snapshots/snapshot_path.hpp>
#include <silkworm/db/stages.hpp>
#include <silkworm/infra/common/ensure.hpp>
Expand Down Expand Up @@ -64,8 +63,8 @@ SnapshotSync::SnapshotSync(
chaindata_env_{chaindata_env},
repository_{settings_, std::make_unique<db::SnapshotBundleFactoryImpl>()},
client_{settings_.bittorrent_settings},
snapshot_freezer_{db::ROAccess{chaindata_env_}, repository_, stage_scheduler, tmp_dir_path, settings.keep_blocks},
snapshot_merger_{repository_, tmp_dir_path},
snapshot_freezer_{db::ROAccess{chaindata_env_}, repository_, stage_scheduler, tmp_dir_path, settings_.keep_blocks},
snapshot_merger_{repository_, std::move(tmp_dir_path)},
is_stopping_latch_{1} {
}

Expand Down Expand Up @@ -267,14 +266,14 @@ Task<void> SnapshotSync::build_missing_indexes() {
SILK_INFO << "SnapshotSync: built missing indexes";
}

void SnapshotSync::update_database(db::RWTxn& txn, BlockNum max_block_available, std::function<bool()> is_stopping) {
void SnapshotSync::update_database(db::RWTxn& txn, BlockNum max_block_available, const std::function<bool()>& is_stopping) {
update_block_headers(txn, max_block_available, is_stopping);
update_block_bodies(txn, max_block_available);
update_block_hashes(txn, max_block_available);
update_block_senders(txn, max_block_available);
}

void SnapshotSync::update_block_headers(db::RWTxn& txn, BlockNum max_block_available, std::function<bool()> is_stopping) {
void SnapshotSync::update_block_headers(db::RWTxn& txn, BlockNum max_block_available, const std::function<bool()>& is_stopping) {
// Check if Headers stage progress has already reached the max block in snapshots
const auto last_progress{db::stages::read_stage_progress(txn, db::stages::kHeadersKey)};
if (last_progress >= max_block_available) {
Expand Down
4 changes: 2 additions & 2 deletions silkworm/db/snapshot_sync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class SnapshotSync {
Task<void> setup_and_run();
Task<void> setup();
Task<void> build_missing_indexes();
void update_database(db::RWTxn& txn, BlockNum max_block_available, std::function<bool()> is_stopping);
void update_block_headers(db::RWTxn& txn, BlockNum max_block_available, std::function<bool()> is_stopping);
void update_database(db::RWTxn& txn, BlockNum max_block_available, const std::function<bool()>& is_stopping);
void update_block_headers(db::RWTxn& txn, BlockNum max_block_available, const std::function<bool()>& is_stopping);
void update_block_bodies(db::RWTxn& txn, BlockNum max_block_available);
static void update_block_hashes(db::RWTxn& txn, BlockNum max_block_available);
static void update_block_senders(db::RWTxn& txn, BlockNum max_block_available);
Expand Down
4 changes: 2 additions & 2 deletions silkworm/db/snapshot_sync_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct SettingsOverrides {

class NoopStageSchedulerAdapter : public stagedsync::StageScheduler {
public:
explicit NoopStageSchedulerAdapter() {}
explicit NoopStageSchedulerAdapter() = default;
~NoopStageSchedulerAdapter() override = default;
Task<void> schedule(std::function<void(db::RWTxn&)> /*callback*/) override {
co_return;
Expand Down Expand Up @@ -81,7 +81,7 @@ struct SnapshotSyncForTest : public SnapshotSync {
};
}

SnapshotSyncForTest(SnapshotSyncTest& test, SettingsOverrides overrides = {})
explicit SnapshotSyncForTest(SnapshotSyncTest& test, SettingsOverrides overrides = {})
: SnapshotSync{
make_settings(test.tmp_dir.path(), overrides),
kMainnetConfig.chain_id,
Expand Down
2 changes: 1 addition & 1 deletion silkworm/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static auto make_execution_server_settings() {
}

NodeImpl::NodeImpl(
[[maybe_unused]] boost::asio::any_io_executor executor,
[[maybe_unused]] boost::asio::any_io_executor executor, // NOLINT(*-unnecessary-value-param)
Settings& settings,
SentryClientPtr sentry_client,
mdbx::env chaindata_env)
Expand Down

0 comments on commit 026b635

Please sign in to comment.