Skip to content

Commit 7d4a517

Browse files
committed
Provide count of segregated txs.
1 parent 53b0e16 commit 7d4a517

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

include/bitcoin/system/chain/block.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class BC_API block
9898
bool is_segregated() const NOEXCEPT;
9999
size_t serialized_size(bool witness) const NOEXCEPT;
100100
size_t signature_operations(bool bip16, bool bip141) const NOEXCEPT;
101+
size_t segregated() const NOEXCEPT;
101102

102103
/// Computed malleation properties.
103104
bool is_malleable() const NOEXCEPT;

src/chain/block.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ bool block::is_segregated() const NOEXCEPT
587587
return std::any_of(txs_->begin(), txs_->end(), segregated);
588588
}
589589

590+
size_t block::segregated() const NOEXCEPT
591+
{
592+
const auto count_segregated = [](const auto& tx) NOEXCEPT
593+
{
594+
return tx->is_segregated();
595+
};
596+
597+
return std::count_if(txs_->begin(), txs_->end(), count_segregated);
598+
}
599+
590600
// The witness merkle root is obtained from wtxids, subject to malleation just
591601
// as the txs commitment. However, since tx duplicates are precluded by the
592602
// malleable32 (or complete) block check, there is no opportunity for this.

test/chain/block.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ BOOST_AUTO_TEST_CASE(block__hash__default__matches_header_hash)
460460
// is_malleable
461461
// is_segregated
462462
// serialized_size
463+
// segregated
463464

464465
// validation (public)
465466
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)