Skip to content
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
5 changes: 3 additions & 2 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace libbitcoin {
namespace node {

settings::settings() NOEXCEPT
: threads{ 1 },
: threads{ 0 },
delay_inbound{ true },
headers_first{ true },
memory_priority{ true },
Expand Down Expand Up @@ -68,7 +68,8 @@ settings::settings(chain::selection) NOEXCEPT

size_t settings::threads_() const NOEXCEPT
{
return std::max<size_t>(threads, one);
// Zero implies hardware threads (including hyperthreads).
return to_bool(threads) ? threads : network::cores();
}

size_t settings::maximum_height_() const NOEXCEPT
Expand Down
4 changes: 2 additions & 2 deletions test/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ BOOST_AUTO_TEST_CASE(configuration__construct1__none_context__expected)

// Just a sample of settings.
BOOST_REQUIRE(instance.node.headers_first);
BOOST_REQUIRE_EQUAL(instance.network.threads, 1_u32);
BOOST_REQUIRE_EQUAL(instance.bitcoin.first_version, 1_u32);
BOOST_REQUIRE_EQUAL(instance.network.threads, 0u);
BOOST_REQUIRE_EQUAL(instance.bitcoin.first_version, 1u);
}

BOOST_AUTO_TEST_SUITE_END()
4 changes: 2 additions & 2 deletions test/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected)
using namespace network;

const node::settings node{};
BOOST_REQUIRE_EQUAL(node.threads, 1_u32);
BOOST_REQUIRE_EQUAL(node.threads, 0_u32);
BOOST_REQUIRE_EQUAL(node.delay_inbound, true);
BOOST_REQUIRE_EQUAL(node.headers_first, true);
BOOST_REQUIRE_EQUAL(node.memory_priority, true);
Expand Down Expand Up @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected)
////BOOST_REQUIRE_EQUAL(node.snapshot_valid, 250'000_u32);
////BOOST_REQUIRE_EQUAL(node.snapshot_confirm, 500'000_u32);

BOOST_REQUIRE_EQUAL(node.threads_(), one);
BOOST_REQUIRE_EQUAL(node.threads_(), cores());
BOOST_REQUIRE_EQUAL(node.maximum_height_(), max_size_t);
BOOST_REQUIRE_EQUAL(node.maximum_concurrency_(), 50'000_size);
BOOST_REQUIRE_EQUAL(node.fee_estimate_horizon_(), 0_size);
Expand Down