File tree Expand file tree Collapse file tree
include/bitcoin/system/chain/enums Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020#define LIBBITCOIN_SYSTEM_CHAIN_ENUMS_MAGIC_NUMBERS_HPP
2121
2222#include < bitcoin/system/define.hpp>
23+ #include < bitcoin/system/math/math.hpp>
2324
2425namespace libbitcoin {
2526namespace system {
@@ -98,6 +99,23 @@ constexpr uint8_t tapscript_version = 0b1100'0000; // 0xc0
9899
99100constexpr size_t max_null_data_size = 80 ;
100101
102+ // / Utilities.
103+ // / ---------------------------------------------------------------------------
104+
105+ constexpr size_t weighted_size (size_t nominal, size_t witnessed) NOEXCEPT
106+ {
107+ return ceilinged_add (
108+ ceilinged_multiply (base_size_contribution, nominal),
109+ ceilinged_multiply (total_size_contribution, witnessed));
110+ }
111+
112+ constexpr size_t virtual_size (size_t nominal, size_t witnessed) NOEXCEPT
113+ {
114+ // Block weight is 3 * nominal size * + 1 * witness size [bip141].
115+ constexpr auto scale = base_size_contribution + total_size_contribution;
116+ return ceilinged_divide (weighted_size (nominal, witnessed), scale);
117+ }
118+
101119} // namespace chain
102120} // namespace system
103121} // namespace libbitcoin
You can’t perform that action at this time.
0 commit comments