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
10 changes: 5 additions & 5 deletions include/bitcoin/node/chasers/chaser_transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class BCN_API chaser_transaction
virtual void get_confirmable_fees(
confirmable_fees_handler&& handler) NOEXCEPT;

/// Least and greatest value of receipts not spent, over conflict outcomes.
virtual void get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT;
/// Totals of receipts, in conflict outcomes of least and greatest value.
virtual void get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT;

/// Count of changes to the pool (thread safe).
uint64_t pool_generation() const NOEXCEPT override;
Expand Down Expand Up @@ -145,9 +145,9 @@ class BCN_API chaser_transaction
const confirmable_txs_handler& handler) NOEXCEPT;
virtual void do_get_confirmable_fees(
const confirmable_fees_handler& handler) NOEXCEPT;
virtual void do_get_unconfirmed_range(
virtual void do_get_unconfirmed_totals(
const database::pool_receipts& receipts,
const unconfirmed_range_handler& handler) NOEXCEPT;
const unconfirmed_totals_handler& handler) NOEXCEPT;

/// Recompute pool context and sweep index by it if due, closing pool if not
/// current or context not reusable, and map scan starts: built once
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/node/full_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ class BCN_API full_node
/// Fee rate tuples of the confirmable txs, in pool order.
void get_confirmable_fees(confirmable_fees_handler&& handler) NOEXCEPT;

/// Least and greatest value of receipts not spent, over conflict outcomes.
void get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT;
/// Totals of receipts, in conflict outcomes of least and greatest value.
void get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT;

/// Handle performance, base returns false (implied terminate).
virtual void performance(object_key channel, uint64_t speed,
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/node/protocols/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ class BCN_API protocol
/// Fee rate tuples of the confirmable txs, in pool order.
void get_confirmable_fees(confirmable_fees_handler&& handler) NOEXCEPT;

/// Least and greatest value of receipts not spent, over conflict outcomes.
void get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT;
/// Totals of receipts, in conflict outcomes of least and greatest value.
void get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT;

/// Suspensions.
/// -----------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/node/sessions/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ class BCN_API session
/// Fee rate tuples of the confirmable txs, in pool order.
void get_confirmable_fees(confirmable_fees_handler&& handler) NOEXCEPT;

/// Least and greatest value of receipts not spent, over conflict outcomes.
void get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT;
/// Totals of receipts, in conflict outcomes of least and greatest value.
void get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT;

/// Handle performance, base returns false (implied terminate).
virtual void performance(object_key channel, uint64_t speed,
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/node/types/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ typedef std::function<void(const code&,
const database::tx_links&)> confirmable_txs_handler;
typedef std::function<void(const code&,
const database::fee_rates&)> confirmable_fees_handler;
typedef std::function<void(const code&, uint64_t,
uint64_t)> unconfirmed_range_handler;
typedef std::function<void(const code&, const database::address_totals&,
const database::address_totals&)> unconfirmed_totals_handler;

/// Event desubscriber.
typedef network::desubscriber<object_key, event_value> event_subscriber;
Expand Down
16 changes: 8 additions & 8 deletions src/chasers/chaser_transaction_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ void chaser_transaction::get_confirmable_fees(
POST(do_get_confirmable_fees, std::move(handler));
}

void chaser_transaction::get_unconfirmed_range(
void chaser_transaction::get_unconfirmed_totals(
const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT
unconfirmed_totals_handler&& handler) NOEXCEPT
{
if (closed())
return;

POST(do_get_unconfirmed_range, receipts, std::move(handler));
POST(do_get_unconfirmed_totals, receipts, std::move(handler));
}

// private
Expand Down Expand Up @@ -313,9 +313,9 @@ void chaser_transaction::do_get_confirmable_fees(
}

// private
void chaser_transaction::do_get_unconfirmed_range(
void chaser_transaction::do_get_unconfirmed_totals(
const database::pool_receipts& receipts,
const unconfirmed_range_handler& handler) NOEXCEPT
const unconfirmed_totals_handler& handler) NOEXCEPT
{
BC_ASSERT(stranded());

Expand All @@ -325,10 +325,10 @@ void chaser_transaction::do_get_unconfirmed_range(
return;
}

uint64_t worst{};
uint64_t best{};
database::address_totals worst{};
database::address_totals best{};
const auto& settings = node_settings().pool;
const auto ec = archive().get_unconfirmed_range(worst, best, receipts,
const auto ec = archive().get_unconfirmed_totals(worst, best, receipts,
settings.maximum_outcomes);
handler(ec, worst, best);
}
Expand Down
6 changes: 3 additions & 3 deletions src/full_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,10 @@ void full_node::get_confirmable_fees(
chaser_transaction_.get_confirmable_fees(std::move(handler));
}

void full_node::get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT
void full_node::get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT
{
chaser_transaction_.get_unconfirmed_range(receipts, std::move(handler));
chaser_transaction_.get_unconfirmed_totals(receipts, std::move(handler));
}

void full_node::performance(object_key key, uint64_t speed,
Expand Down
6 changes: 3 additions & 3 deletions src/protocols/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ void protocol::get_confirmable_fees(confirmable_fees_handler&& handler) NOEXCEPT
session_->get_confirmable_fees(std::move(handler));
}

void protocol::get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT
void protocol::get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT
{
session_->get_unconfirmed_range(receipts, std::move(handler));
session_->get_unconfirmed_totals(receipts, std::move(handler));
}

// Events subscription.
Expand Down
6 changes: 3 additions & 3 deletions src/sessions/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ void session::get_confirmable_fees(confirmable_fees_handler&& handler) NOEXCEPT
node_.get_confirmable_fees(std::move(handler));
}

void session::get_unconfirmed_range(const database::pool_receipts& receipts,
unconfirmed_range_handler&& handler) NOEXCEPT
void session::get_unconfirmed_totals(const database::pool_receipts& receipts,
unconfirmed_totals_handler&& handler) NOEXCEPT
{
node_.get_unconfirmed_range(receipts, std::move(handler));
node_.get_unconfirmed_totals(receipts, std::move(handler));
}

void session::performance(object_key key, uint64_t speed,
Expand Down
26 changes: 13 additions & 13 deletions test/chasers/chaser_transaction_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,34 +165,34 @@ BC_FIXTURE_TEST_CASE(chaser_transaction__get_confirmable_fees__relay_off_pooled_
BC_REQUIRE(rates.empty());
}

// get_unconfirmed_range
// get_unconfirmed_totals

BC_FIXTURE_TEST_CASE(chaser_transaction__get_unconfirmed_range__no_receipts__zeros, chaser_transaction_pooling_setup_fixture)
BC_FIXTURE_TEST_CASE(chaser_transaction__get_unconfirmed_totals__no_receipts__zeros, chaser_transaction_pooling_setup_fixture)
{
const auto [ec, worst, best] = get_unconfirmed_range({});
const auto [ec, worst, best] = get_unconfirmed_totals({});
BC_REQUIRE_EQUAL(ec, database::error::success);
BC_REQUIRE_EQUAL(worst, 0u);
BC_REQUIRE_EQUAL(best, 0u);
BC_REQUIRE_EQUAL(worst.funded_count, 0u);
BC_REQUIRE_EQUAL(best.funded_count, 0u);
}

BC_FIXTURE_TEST_CASE(chaser_transaction__get_unconfirmed_range__pooled_tx__its_value, chaser_transaction_pooling_setup_fixture)
BC_FIXTURE_TEST_CASE(chaser_transaction__get_unconfirmed_totals__pooled_tx__its_value, chaser_transaction_pooling_setup_fixture)
{
const auto tx = spend(parent_value - 1'000);
const auto result = submit(package({ tx }));
const auto row = query_.to_pool_row(query_.to_tx(tx->hash(false)));
const auto [ec, worst, best] = get_unconfirmed_range({ { row.value, 42u, {} } });
const auto [ec, worst, best] = get_unconfirmed_totals({ { row.value, 42u, {} } });
BC_REQUIRE_EQUAL(result.first, node::error::success);
BC_REQUIRE_EQUAL(ec, database::error::success);
BC_REQUIRE_EQUAL(worst, 42u);
BC_REQUIRE_EQUAL(best, 42u);
BC_REQUIRE_EQUAL(worst.funded_value, 42u);
BC_REQUIRE_EQUAL(best.funded_value, 42u);
}

BC_FIXTURE_TEST_CASE(chaser_transaction__get_unconfirmed_range__row_not_pooled__zeros, chaser_transaction_pooling_setup_fixture)
BC_FIXTURE_TEST_CASE(chaser_transaction__get_unconfirmed_totals__row_not_pooled__zeros, chaser_transaction_pooling_setup_fixture)
{
const auto [ec, worst, best] = get_unconfirmed_range({ { 0u, 42u, {} } });
const auto [ec, worst, best] = get_unconfirmed_totals({ { 0u, 42u, {} } });
BC_REQUIRE_EQUAL(ec, database::error::success);
BC_REQUIRE_EQUAL(worst, 0u);
BC_REQUIRE_EQUAL(best, 0u);
BC_REQUIRE_EQUAL(worst.funded_count, 0u);
BC_REQUIRE_EQUAL(best.funded_count, 0u);
}

// estimate
Expand Down
11 changes: 6 additions & 5 deletions test/chasers/chaser_transaction_setup_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,13 @@ struct chaser_transaction_setup_fixture
return promise.get_future().get();
}

using ranged = std::tuple<code, uint64_t, uint64_t>;
ranged get_unconfirmed_range(const database::pool_receipts& receipts)
using totals = database::address_totals;
using totaled = std::tuple<code, totals, totals>;
totaled get_unconfirmed_totals(const database::pool_receipts& receipts)
{
std::promise<ranged> promise{};
node_.get_unconfirmed_range(receipts, [&](const code& ec,
uint64_t worst, uint64_t best) NOEXCEPT
std::promise<totaled> promise{};
node_.get_unconfirmed_totals(receipts, [&](const code& ec,
const totals& worst, const totals& best) NOEXCEPT
{
promise.set_value({ ec, worst, best });
});
Expand Down
Loading