Skip to content

Commit 8eaad90

Browse files
committed
Add get_tx_fees, rename get_block_fees.
1 parent 7d3e3d2 commit 8eaad90

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

include/bitcoin/database/impl/query/estimate.ipp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
namespace libbitcoin {
3131
namespace database {
3232

33+
TEMPLATE
34+
bool CLASS::get_tx_fees(fee_rate& out, const tx_link& link) const NOEXCEPT
35+
{
36+
const auto tx = get_transaction(link, false);
37+
if (!tx || !populate_without_metadata(*tx))
38+
return false;
39+
40+
out.bytes = tx->virtual_size();
41+
out.fee = tx->fee();
42+
return true;
43+
}
44+
3345
TEMPLATE
3446
bool CLASS::get_block_fees(fee_rates& out,
3547
const header_link& link) const NOEXCEPT
@@ -55,7 +67,7 @@ bool CLASS::get_block_fees(fee_rates& out,
5567
}
5668

5769
TEMPLATE
58-
bool CLASS::get_block_fees(std::atomic_bool& cancel, fee_rate_sets& out,
70+
bool CLASS::get_branch_fees(std::atomic_bool& cancel, fee_rate_sets& out,
5971
size_t top, size_t count) const NOEXCEPT
6072
{
6173
out.clear();

include/bitcoin/database/impl/query/validate.ipp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ code CLASS::get_block_state(const header_link& link) const NOEXCEPT
141141
}
142142

143143
TEMPLATE
144-
uint64_t CLASS::get_block_fees(const header_link& link) const NOEXCEPT
144+
uint64_t CLASS::get_block_fee(const header_link& link) const NOEXCEPT
145145
{
146146
// TODO: optimize.
147147
const auto block = get_block(link, false);

include/bitcoin/database/query.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,13 @@ class query
401401
/// Services.
402402
/// -----------------------------------------------------------------------
403403

404-
/// Gether fee rate tuples by block or set of blocks.
404+
uint64_t get_tx_fee(const tx_link& link) const NOEXCEPT;
405+
uint64_t get_block_fee(const header_link& link) const NOEXCEPT;
406+
407+
/// Gether fee rate tuples by tx, block or branch.
408+
bool get_tx_fees(fee_rate& out, const tx_link& link) const NOEXCEPT;
405409
bool get_block_fees(fee_rates& out, const header_link& link) const NOEXCEPT;
406-
bool get_block_fees(std::atomic_bool& cancel, fee_rate_sets& out,
410+
bool get_branch_fees(std::atomic_bool& cancel, fee_rate_sets& out,
407411
size_t top, size_t count) const NOEXCEPT;
408412

409413
/// Merkle computations over the index of confirmed headers.
@@ -476,8 +480,6 @@ class query
476480

477481
/// States.
478482
bool is_validateable(size_t height) const NOEXCEPT;
479-
uint64_t get_tx_fee(const tx_link& link) const NOEXCEPT;
480-
uint64_t get_block_fees(const header_link& link) const NOEXCEPT;
481483
code get_block_state(const header_link& link) const NOEXCEPT;
482484
code get_header_state(const header_link& link) const NOEXCEPT;
483485
code get_tx_state(const tx_link& link, const context& ctx) const NOEXCEPT;

0 commit comments

Comments
 (0)