File tree Expand file tree Collapse file tree 5 files changed +20
-0
lines changed
Expand file tree Collapse file tree 5 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,9 @@ class BCN_API chaser
9393 // / Reset store disk full condition.
9494 virtual code reload (const store::event_handler& handler) NOEXCEPT;
9595
96+ // / Get reorganization lock.
97+ virtual lock get_reorganization_lock () NOEXCEPT;
98+
9699 // / Events.
97100 // / -----------------------------------------------------------------------
98101
Original file line number Diff line number Diff line change 2222// / Standard includes (do not include directly).
2323#include < functional>
2424#include < memory>
25+ #include < mutex>
2526#include < utility>
2627#include < variant>
2728
@@ -57,6 +58,7 @@ typedef std::error_code code;
5758typedef std::function<void (const code&, size_t )> organize_handler;
5859typedef database::store<database::map> store;
5960typedef database::query<store> query;
61+ typedef std::unique_lock<std::mutex> lock;
6062
6163// / Work types.
6264typedef network::race_all<const code&> job;
Original file line number Diff line number Diff line change @@ -139,6 +139,10 @@ class BCN_API full_node
139139 // / Get the memory resource.
140140 virtual network::memory& get_memory () NOEXCEPT;
141141
142+ // / Get reorganization lock.
143+ // / Used to prevent candidate chain reorganization during confirmation.
144+ virtual lock get_reorganization_lock () NOEXCEPT;
145+
142146protected:
143147 // / Session attachments.
144148 // / -----------------------------------------------------------------------
@@ -161,6 +165,7 @@ class BCN_API full_node
161165
162166 // These are thread safe.
163167 const configuration& config_;
168+ std::mutex reorganization_mutex_{};
164169 memory_controller memory_;
165170 query& query_;
166171
Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ code chaser::reload(const store::event_handler& handler) NOEXCEPT
8383 return node_.reload (handler);
8484}
8585
86+ lock chaser::get_reorganization_lock () NOEXCEPT
87+ {
88+ return node_.get_reorganization_lock ();
89+ }
90+
8691// Events.
8792// ----------------------------------------------------------------------------
8893
Original file line number Diff line number Diff line change @@ -370,6 +370,11 @@ network::memory& full_node::get_memory() NOEXCEPT
370370 return memory_;
371371}
372372
373+ lock full_node::get_reorganization_lock () NOEXCEPT
374+ {
375+ return lock{ reorganization_mutex_ };
376+ }
377+
373378// Session attachments.
374379// ----------------------------------------------------------------------------
375380
You can’t perform that action at this time.
0 commit comments