Skip to content

Commit

Permalink
Move nano::store::writer enum to a dedicated header
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Dec 31, 2024
1 parent d5b3379 commit 2d3668d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
1 change: 0 additions & 1 deletion nano/node/confirming_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <nano/secure/ledger_set_any.hpp>
#include <nano/secure/ledger_set_confirmed.hpp>
#include <nano/store/component.hpp>
#include <nano/store/write_queue.hpp>

nano::confirming_set::confirming_set (confirming_set_config const & config_a, nano::ledger & ledger_a, nano::block_processor & block_processor_a, nano::stats & stats_a, nano::logger & logger_a) :
config{ config_a },
Expand Down
4 changes: 3 additions & 1 deletion nano/store/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ add_library(
version.cpp
versioning.cpp
write_queue.hpp
write_queue.cpp)
write_queue.cpp
writers.hpp
writers.cpp)

target_link_libraries(
nano_store
Expand Down
17 changes: 2 additions & 15 deletions nano/store/write_queue.hpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
#pragma once

#include <nano/lib/locks.hpp>
#include <nano/store/writers.hpp>

#include <condition_variable>
#include <deque>
#include <functional>

namespace nano::store
{
/** Distinct areas write locking is done, order is irrelevant */
enum class writer
{
generic,
node,
block_processor,
confirmation_height,
pruning,
voting_final,
bounded_backlog,
online_weight,
testing // Used in tests to emulate a write lock
};

class write_queue;

class write_guard final
Expand Down Expand Up @@ -80,4 +67,4 @@ class write_queue final

std::function<void ()> guard_finish_callback;
};
} // namespace nano::store
}
7 changes: 7 additions & 0 deletions nano/store/writers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <nano/lib/enum_util.hpp>
#include <nano/store/writers.hpp>

std::string_view nano::store::to_string (nano::store::writer writer)
{
return nano::enum_util::name (writer);
}
20 changes: 20 additions & 0 deletions nano/store/writers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

namespace nano::store
{
/** Distinct areas write locking is done, order is irrelevant */
enum class writer
{
generic,
node,
block_processor,
confirmation_height,
pruning,
voting_final,
bounded_backlog,
online_weight,
testing // Used in tests to emulate a write lock
};

std::string_view to_string (writer);
}

0 comments on commit 2d3668d

Please sign in to comment.