Skip to content

Commit 289fe55

Browse files
authored
Merge pull request #776 from evoskuil/master
Documentation comments on unspent and history.
2 parents ed7b9cb + 2b3733b commit 289fe55

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

include/bitcoin/database/types/history.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,37 @@ namespace database {
2727

2828
struct BCD_API history
2929
{
30+
/// unrooted_height maps to -1 in the Electrum json-rpc.
3031
static constexpr size_t rooted_height = zero;
3132
static constexpr size_t unrooted_height = max_size_t;
3233
static constexpr size_t unconfirmed_position = max_size_t;
3334
static constexpr uint64_t missing_prevout = max_uint64;
3435

36+
/// Filter out invalid history elements (txs) and sort.
3537
static void filter_sort_and_dedup(std::vector<history>& history) NOEXCEPT;
3638

39+
/// The tx is valid (not defaulted).
3740
bool valid() const NOEXCEPT;
41+
42+
/// The unconfirmed tx is rooted in chain (all prevouts confirmed).
3843
bool rooted() const NOEXCEPT;
44+
45+
/// The tx is confirmed in a block.
3946
bool confirmed() const NOEXCEPT;
47+
48+
/// Comparison operator based on Electrum history status sort.
4049
bool operator<(const history& other) const NOEXCEPT;
50+
51+
/// Equivalence: !LT && !GT (note that fee is never considered).
4152
bool operator==(const history& other) const NOEXCEPT;
4253

54+
/// Tx hash and block height, or rooted/unrooted_height if unconfirmed.
4355
checkpoint tx{};
56+
57+
/// Tx fee, or history::missing_prevout for missing, confirmed, or -fee.
4458
uint64_t fee{};
59+
60+
/// Tx's position in confirmed block, or history::unconfirmed_position.
4561
size_t position{};
4662
};
4763

include/bitcoin/database/types/unspent.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,28 @@ struct BCD_API unspent
3030
static constexpr size_t unused_height = zero;
3131
static constexpr size_t unconfirmed_position = max_size_t;
3232

33+
/// Filter out invalid unspent output elements and sort.
3334
static void filter_sort_and_dedup(std::vector<unspent>& unspent) NOEXCEPT;
3435

36+
/// The outpoint is valid (not defaulted).
3537
bool valid() const NOEXCEPT;
38+
39+
/// The tx is confirmed in a block.
3640
bool confirmed() const NOEXCEPT;
41+
42+
/// Comparison operator based on Electrum unspent status sort.
3743
bool operator<(const unspent& other) const NOEXCEPT;
44+
45+
/// Equivalence: !LT && !GT (note that fee is never considered).
3846
bool operator==(const unspent& other) const NOEXCEPT;
3947

48+
/// Tx hash and index of output within the tx.
4049
outpoint out{};
50+
51+
/// Tx's block height if confirmed, or unspent::unused_height.
4152
size_t height{};
53+
54+
/// Tx's position in confirmed block, or unspent::unconfirmed_position.
4255
size_t position{};
4356
};
4457

0 commit comments

Comments
 (0)