diff --git a/include/bitcoin/node/chasers/chaser_transaction.hpp b/include/bitcoin/node/chasers/chaser_transaction.hpp index 788691008..21a869690 100644 --- a/include/bitcoin/node/chasers/chaser_transaction.hpp +++ b/include/bitcoin/node/chasers/chaser_transaction.hpp @@ -83,7 +83,7 @@ class BCN_API chaser_transaction code validate(size_t& index, const system::chain::transaction_cptrs& txs, const std::vector& 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( diff --git a/include/bitcoin/node/settings.hpp b/include/bitcoin/node/settings.hpp index 6835b2efa..672f75c0a 100644 --- a/include/bitcoin/node/settings.hpp +++ b/include/bitcoin/node/settings.hpp @@ -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; diff --git a/src/chasers/chaser_snapshot.cpp b/src/chasers/chaser_snapshot.cpp index 3b8149c2c..cbb529925 100644 --- a/src/chasers/chaser_snapshot.cpp +++ b/src/chasers/chaser_snapshot.cpp @@ -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(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; } diff --git a/src/chasers/chaser_transaction.cpp b/src/chasers/chaser_transaction.cpp index af653488b..c9ee051fe 100644 --- a/src/chasers/chaser_transaction.cpp +++ b/src/chasers/chaser_transaction.cpp @@ -554,7 +554,7 @@ 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()); @@ -562,15 +562,24 @@ code chaser_transaction::validate(size_t& index, const transaction_cptrs& txs, 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{}; @@ -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; } diff --git a/src/estimator.cpp b/src/estimator.cpp index 7a258235d..904c794a4 100644 --- a/src/estimator.cpp +++ b/src/estimator.cpp @@ -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; } @@ -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); } } @@ -322,7 +322,7 @@ 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{}; @@ -330,10 +330,10 @@ bool estimator::update(const rates& block, size_t height, bool push) NOEXCEPT 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. diff --git a/src/settings.cpp b/src/settings.cpp index 691920ba5..26418984d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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 }, diff --git a/test/settings.cpp b/test/settings.cpp index 23a9e0eaa..7a3a8638f 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -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); @@ -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());