File tree Expand file tree Collapse file tree 4 files changed +15
-1
lines changed
include/bitcoin/system/chain Expand file tree Collapse file tree 4 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ class BC_API block
100100 size_t segregated () const NOEXCEPT;
101101 size_t serialized_size (bool witness) const NOEXCEPT;
102102 size_t signature_operations (bool bip16, bool bip141) const NOEXCEPT;
103+ size_t virtual_size () const NOEXCEPT;
103104
104105 // / Computed malleation properties.
105106 bool is_malleable () const NOEXCEPT;
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ class BC_API transaction
111111 bool is_segregated () const NOEXCEPT;
112112 hash_digest hash (bool witness) const NOEXCEPT;
113113 size_t serialized_size (bool witness) const NOEXCEPT;
114+ size_t virtual_size () const NOEXCEPT;
114115
115116 // / Cache setters/getters, not thread safe.
116117 // / -----------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -481,6 +481,12 @@ size_t block::weight() const NOEXCEPT
481481 ceilinged_multiply (total_size_contribution, serialized_size (true )));
482482}
483483
484+ size_t block::virtual_size () const NOEXCEPT
485+ {
486+ constexpr auto scale = base_size_contribution + total_size_contribution;
487+ return ceilinged_divide (weight (), scale);
488+ }
489+
484490bool block::is_overweight () const NOEXCEPT
485491{
486492 return weight () > max_block_weight;
Original file line number Diff line number Diff line change @@ -563,12 +563,18 @@ bool transaction::is_segregated() const NOEXCEPT
563563
564564size_t transaction::weight () const NOEXCEPT
565565{
566- // Block weight is 3 * base size * + 1 * total size [bip141].
566+ // Transaction weight is 3 * base size * + 1 * total size [bip141].
567567 return ceilinged_add (
568568 ceilinged_multiply (base_size_contribution, serialized_size (false )),
569569 ceilinged_multiply (total_size_contribution, serialized_size (true )));
570570}
571571
572+ size_t transaction::virtual_size () const NOEXCEPT
573+ {
574+ constexpr auto scale = base_size_contribution + total_size_contribution;
575+ return ceilinged_divide (weight (), scale);
576+ }
577+
572578bool transaction::is_overweight () const NOEXCEPT
573579{
574580 return weight () > max_block_weight;
You can’t perform that action at this time.
0 commit comments