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
2 changes: 1 addition & 1 deletion include/bitcoin/node/chasers/chaser_transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BCN_API chaser_transaction

code validate(size_t& index, const system::chain::transaction_cptrs& txs,
const std::vector<bool>& stored) NOEXCEPT;
code validate(const system::chain::transaction& tx) NOEXCEPT;
code accept(const system::chain::transaction& tx) NOEXCEPT;
code validate(const system::chain::transaction& tx,
const system::chain::context& ctx) NOEXCEPT;
database::tx_link to_stored(
Expand Down
1 change: 0 additions & 1 deletion include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class BCN_API settings
bool cpu_batch_silent;
float allowed_deviation;
double minimum_fee_rate;
double minimum_bump_rate;
uint64_t batch_verify;
uint64_t batch_silent;
uint16_t current_connections;
Expand Down
26 changes: 0 additions & 26 deletions src/chasers/chaser_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,6 @@ code chaser_snapshot::start() NOEXCEPT
////if (enabled_confirm_)
//// confirm_ = std::max(archive().get_top_confirmed(), checkpoint());

// Prune on startup when coalesced above genesis, before the network starts.
const auto& query = archive();
if (!is_zero(query.get_top_confirmed()) && query.is_coalesced())
{
LOG_ONLY(const auto begin = logger::now();)
if (const auto ec = query.prune([this](auto LOG_ONLY(event_),
auto LOG_ONLY(table)) NOEXCEPT
{
LOGN("snapshot::" << full_node::store::events.at(event_)
<< "(" << full_node::store::tables.at(table) << ")");
}))
{
LOGF("Prune deferred, " << ec.message());
}
else
{
pruned_.store(true, std::memory_order_relaxed);
const header_t top = query.to_confirmed(query.get_top_confirmed());
notify(error::success, chases::pruned{ top });
LOG_ONLY(const auto time = logger::now() - begin;)
LOG_ONLY(const auto span = duration_cast<milliseconds>(time);)
LOGN("Pruned prevout cache at height [" << query.get_top_confirmed()
<< "] complete in " << span.count() << " msecs.");
}
}

SUBSCRIBE_CHASE(handle_chase, _1, _2);
return error::success;
}
Expand Down
24 changes: 15 additions & 9 deletions src/chasers/chaser_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,23 +554,32 @@ code chaser_transaction::validate(size_t& index, const transaction_cptrs& txs,
continue;

const auto& tx = *txs.at(index);
if (const auto ec = validate(tx))
if (const auto ec = accept(tx))
return ec;

fee = ceilinged_add(fee, tx.fee());
size = ceilinged_add(size, possible_wide_cast<uint64_t>(
tx.virtual_size()));
}

index = zero;

// Compared in satoshis per virtual kilobyte.
const auto rate = node_settings().minimum_fee_rate_();
return ceilinged_multiply(fee, 1'000_u64) < ceilinged_multiply(rate, size) ?
error::insufficient_fee : error::success;
if (ceilinged_multiply(fee, 1'000_u64) < ceilinged_multiply(rate, size))
{
index = zero;
return error::insufficient_fee;
}

// Script validation is the most costly, so it follows the guards.
for (index = zero; index < txs.size(); ++index)
if (!stored.at(index))
if (const auto ec = txs.at(index)->connect(pool_))
return ec;

return error::success;
}

code chaser_transaction::validate(const chain::transaction& tx) NOEXCEPT
code chaser_transaction::accept(const chain::transaction& tx) NOEXCEPT
{
code ec{};

Expand All @@ -587,9 +596,6 @@ code chaser_transaction::validate(const chain::transaction& tx) NOEXCEPT
if (!ec) ec = tx.accept(pool_);
if (!ec) ec = tx.accept_guard(pool_);
if (!ec) ec = tx.confirm_guard(pool_);

// Script validation is the most costly, so it follows the guards.
if (!ec) ec = tx.connect(pool_);
return ec;
}

Expand Down
14 changes: 7 additions & 7 deletions src/estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ bool estimator::pool(const rate& tx) NOEXCEPT
return false;

// The store does not pool, so there is no entry height.
if (tx.height == max_size_t)
if (tx.pooled_height == max_size_t)
return true;

size_t bin{};
if (to_bin(bin, tx))
pend(bin, tx.height, true);
pend(bin, tx.pooled_height, true);

return true;
}
Expand All @@ -229,8 +229,8 @@ void estimator::conflict(const rates& txs, bool push) NOEXCEPT
for (const auto& tx: txs)
{
size_t bin{};
if (tx.height != max_size_t && to_bin(bin, tx))
pend(bin, tx.height, !push);
if (tx.pooled_height != max_size_t && to_bin(bin, tx))
pend(bin, tx.pooled_height, !push);
}
}

Expand Down Expand Up @@ -322,18 +322,18 @@ bool estimator::update(const rates& block, size_t height, bool push) NOEXCEPT
return false;

// A tx not pooled before its block has no wait.
if (tx.height == max_size_t)
if (tx.pooled_height == max_size_t)
continue;

size_t bin{};
if (!to_bin(bin, tx))
continue;

// Blocks waited beyond the first eligible, capped at the horizon.
const auto waited = std::min(floored_subtract(height, tx.height), large);
const auto waited = std::min(floored_subtract(height, tx.pooled_height), large);
++counts.at(bin);
++waits_.at(bin).at(waited);
pend(bin, tx.height, !push);
pend(bin, tx.pooled_height, !push);
}

// At age zero scale term is one.
Expand Down
3 changes: 1 addition & 2 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ settings::settings() NOEXCEPT
cpu_batch_silent{ false },
allowed_deviation{ 1.5 },
minimum_fee_rate{ 0.000001 },
minimum_bump_rate{ 0.0 },
batch_verify{ 1'000'000 },
batch_silent{ 1'000'000 },
current_connections{ 10 },
fee_estimate_horizon{ 1008 },
fee_estimate_horizon{ 0 },
////snapshot_bytes{ 200'000'000'000 },
////snapshot_valid{ 250'000 },
////snapshot_confirm{ 500'000 },
Expand Down
7 changes: 3 additions & 4 deletions test/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ BC_AUTO_TEST_CASE(settings__node__default_context__expected)
BC_REQUIRE_EQUAL(node.cpu_batch_silent, false);
BC_REQUIRE_EQUAL(node.minimum_fee_rate, 0.000001);
BC_REQUIRE_EQUAL(node.minimum_fee_rate_(), 100_u64);
BC_REQUIRE_EQUAL(node.minimum_bump_rate, 0.0);
BC_REQUIRE_EQUAL(node.allowed_deviation, 1.5);
BC_REQUIRE_EQUAL(node.batch_verify, 1'000'000_u64);
BC_REQUIRE_EQUAL(node.batch_silent, 1'000'000_u64);
BC_REQUIRE_EQUAL(node.current_connections, 10_u16);
BC_REQUIRE_EQUAL(node.fee_estimate_horizon, 1008u);
BC_REQUIRE_EQUAL(node.fee_estimate_horizon, 0u);
BC_REQUIRE_EQUAL(node.maximum_height, 0_u32);
BC_REQUIRE_EQUAL(node.maximum_height_(), max_size_t);
BC_REQUIRE_EQUAL(node.silent_start_height, 0xffffffff_u32);
Expand All @@ -69,8 +68,8 @@ BC_AUTO_TEST_CASE(settings__node__default_context__expected)
BC_REQUIRE_EQUAL(node.threads_(), cores());
BC_REQUIRE_EQUAL(node.maximum_height_(), max_size_t);
BC_REQUIRE_EQUAL(node.maximum_concurrency_(), 50'000_size);
BC_REQUIRE_EQUAL(node.fee_estimate_horizon_(), 1008_size);
BC_REQUIRE(node.fee_estimate_enabled());
BC_REQUIRE_EQUAL(node.fee_estimate_horizon_(), 0_size);
BC_REQUIRE(!node.fee_estimate_enabled());
BC_REQUIRE_EQUAL(node.use_gpu_(), system::batched::accelerated());
BC_REQUIRE(node.batch_verify_enabled());
BC_REQUIRE(node.batch_silent_enabled());
Expand Down
Loading