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
3 changes: 2 additions & 1 deletion include/bitcoin/node/chasers/chaser_confirm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ class BCN_API chaser_confirm
size_t top) NOEXCEPT;
void announce(const header_link& link, height_t height) NOEXCEPT;

// This is thread safe.
// These are thread safe.
const bool filter_;
const bool defer_;
};

} // namespace node
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/chasers/chaser_validate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class BCN_API chaser_validate
const size_t maximum_backlog_;
const bool node_witness_;
const bool filter_;
const bool defer_;
};

} // namespace node
Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class BCN_API settings
bool headers_first;
bool thread_priority;
bool memory_priority;
bool defer_validation;
bool defer_confirmation;
float allowed_deviation;
uint16_t announcement_cache;
uint16_t allocation_multiple;
Expand Down
9 changes: 7 additions & 2 deletions src/chasers/chaser_confirm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)

chaser_confirm::chaser_confirm(full_node& node) NOEXCEPT
: chaser(node),
filter_(node.archive().filter_enabled())
filter_(node.archive().filter_enabled()),
defer_(node.config().node.defer_confirmation)
{
}

Expand All @@ -49,7 +50,11 @@ code chaser_confirm::start() NOEXCEPT
LOGN("Node is current at startup block [" << position() << "].");
}

SUBSCRIBE_EVENTS(handle_event, _1, _2, _3);
if (!defer_)
{
SUBSCRIBE_EVENTS(handle_event, _1, _2, _3);
}

return error::success;
}

Expand Down
18 changes: 13 additions & 5 deletions src/chasers/chaser_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT
initial_subsidy_(node.config().bitcoin.initial_subsidy()),
maximum_backlog_(node.config().node.maximum_concurrency_()),
node_witness_(node.config().network.witness_node()),
filter_(node.archive().filter_enabled())
filter_(node.archive().filter_enabled()),
defer_(node.config().node.defer_validation)
{
}

Expand Down Expand Up @@ -170,12 +171,13 @@ void chaser_validate::do_bumped(height_t height) NOEXCEPT
if (ec == database::error::unassociated)
return;

const auto bypass = is_under_checkpoint(height) ||
const auto bypass = defer_ || is_under_checkpoint(height) ||
query.is_milestone(link);

if (bypass)
{
if (filter_)
// Filters will be set on subsequent unsupressed run.
if (filter_ && !defer_)
{
post_block(link, bypass);
}
Expand Down Expand Up @@ -350,9 +352,15 @@ void chaser_validate::complete_block(const code& ec, const header_link& link,
}

// VALID BLOCK
// Under deferral there is no state change, but downloads will stall unless
// he window is closed out, so notify the check chaser of the increment.
notify(ec, chase::valid, possible_wide_cast<height_t>(height));
fire(events::block_validated, height);
LOGV("Block validated: " << height << (bypass ? " (bypass)" : ""));

if (!defer_)
{
fire(events::block_validated, height);
LOGV("Block validated: " << height << (bypass ? " (bypass)" : ""));
}
}

// Overrides due to independent priority thread pool
Expand Down
10 changes: 10 additions & 0 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,16 @@ options_metadata parser::load_settings() THROWS
value<bool>(&configured.node.delay_inbound),
"Delay accepting inbound connections until node is current, defaults to 'true'."
)
(
"node.defer_validation",
value<bool>(&configured.node.defer_validation),
"Defer validation, defaults to 'false'."
)
(
"node.defer_confirmation",
value<bool>(&configured.node.defer_confirmation),
"Defer confirmation, defaults to 'false'."
)
////(
//// "node.headers_first",
//// value<bool>(&configured.node.headers_first),
Expand Down
2 changes: 2 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ settings::settings() NOEXCEPT
headers_first{ true },
memory_priority{ true },
thread_priority{ true },
defer_validation{ false },
defer_confirmation{ false },
allowed_deviation{ 1.5 },
announcement_cache{ 42 },
allocation_multiple{ 20 },
Expand Down
2 changes: 2 additions & 0 deletions test/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected)
BOOST_REQUIRE_EQUAL(node.thread_priority, true);
BOOST_REQUIRE_EQUAL(node.delay_inbound, true);
BOOST_REQUIRE_EQUAL(node.headers_first, true);
BOOST_REQUIRE_EQUAL(node.defer_validation, false);
BOOST_REQUIRE_EQUAL(node.defer_confirmation, false);
BOOST_REQUIRE_EQUAL(node.allowed_deviation, 1.5);
BOOST_REQUIRE_EQUAL(node.announcement_cache, 42_u16);
BOOST_REQUIRE_EQUAL(node.allocation_multiple, 20_u16);
Expand Down
Loading