Skip to content

Commit

Permalink
Fix validate/confirm threadpool/strand initialization order.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jan 5, 2025
1 parent 0558cdf commit 7baf31b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
14 changes: 7 additions & 7 deletions include/bitcoin/node/chasers/chaser_confirm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ class BCN_API chaser_confirm
bool get_is_strong(bool& strong, const uint256_t& fork_work,
size_t fork_point) const NOEXCEPT;

// These are thread safe.
const bool concurrent_;
network::asio::strand independent_strand_;

// These are protected by strand.
network::threadpool threadpool_;
neutrino_header neutrino_{};
bool filters_{};
bool mature_{};
bool filters_{};
neutrino_header neutrino_{};
network::threadpool threadpool_;

// These are thread safe.
network::asio::strand independent_strand_;
const bool concurrent_;
};

} // namespace node
Expand Down
18 changes: 9 additions & 9 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ class BCN_API chaser_validate
return backlog_ < maximum_backlog_;
}

// These are thread safe.
const bool concurrent_;
const size_t maximum_backlog_;
const uint64_t initial_subsidy_;
const uint32_t subsidy_interval_;
network::asio::strand independent_strand_;

// These are protected by strand.
network::threadpool threadpool_;
size_t backlog_{};
bool mature_{};
size_t backlog_{};
network::threadpool threadpool_;

// These are thread safe.
network::asio::strand independent_strand_;
const uint32_t subsidy_interval_;
const uint64_t initial_subsidy_;
const size_t maximum_backlog_;
const bool concurrent_;
};

} // namespace node
Expand Down
4 changes: 2 additions & 2 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
// Higher priority than validator ensures locality to validator reads.
chaser_confirm::chaser_confirm(full_node& node) NOEXCEPT
: chaser(node),
concurrent_(node.config().node.concurrent_confirmation),
threadpool_(one, node.config().node.priority_()),
independent_strand_(threadpool_.service().get_executor())
independent_strand_(threadpool_.service().get_executor()),
concurrent_(node.config().node.concurrent_confirmation)
{
}

Expand Down
10 changes: 5 additions & 5 deletions src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
// Higher priority than downloader (net) ensures locality to downloader writes.
chaser_validate::chaser_validate(full_node& node) NOEXCEPT
: chaser(node),
concurrent_(node.config().node.concurrent_validation),
maximum_backlog_(node.config().node.maximum_concurrency_()),
initial_subsidy_(node.config().bitcoin.initial_subsidy()),
subsidy_interval_(node.config().bitcoin.subsidy_interval_blocks),
threadpool_(node.config().node.threads_(), node.config().node.priority_()),
independent_strand_(threadpool_.service().get_executor())
independent_strand_(threadpool_.service().get_executor()),
subsidy_interval_(node.config().bitcoin.subsidy_interval_blocks),
initial_subsidy_(node.config().bitcoin.initial_subsidy()),
maximum_backlog_(node.config().node.maximum_concurrency_()),
concurrent_(node.config().node.concurrent_validation)
{
}

Expand Down

0 comments on commit 7baf31b

Please sign in to comment.