From f16e266dfb6312ee805234a2b45595f2a41a854c Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 21 Jul 2024 15:15:19 -0400 Subject: [PATCH 1/3] Comments. --- include/bitcoin/system/chain/header.hpp | 1 - include/bitcoin/system/chain/transaction.hpp | 1 - 2 files changed, 2 deletions(-) diff --git a/include/bitcoin/system/chain/header.hpp b/include/bitcoin/system/chain/header.hpp index 0a5c2d3b02..99545c17f6 100644 --- a/include/bitcoin/system/chain/header.hpp +++ b/include/bitcoin/system/chain/header.hpp @@ -153,7 +153,6 @@ class BC_API header bool valid_; // Identity hash caching. - // TODO: use std::optional to avoid this pointer allocation. mutable std::shared_ptr hash_{}; }; diff --git a/include/bitcoin/system/chain/transaction.hpp b/include/bitcoin/system/chain/transaction.hpp index 0499301d49..16067ab9d7 100644 --- a/include/bitcoin/system/chain/transaction.hpp +++ b/include/bitcoin/system/chain/transaction.hpp @@ -274,7 +274,6 @@ class BC_API transaction bool valid_; sizes size_; - // TODO: use std::optional to avoid these pointer allocations (0.16%). // Signature and identity hash caching (witness hash if witnessed). mutable std::unique_ptr nominal_hash_{}; mutable std::unique_ptr witness_hash_{}; From f2276c26e51789f856f0f181214b4c5155859182 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 21 Jul 2024 15:15:38 -0400 Subject: [PATCH 2/3] Add header size static_assert test case. --- test/chain/header.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/chain/header.cpp b/test/chain/header.cpp index 1cb5f0518d..7f035029e9 100644 --- a/test/chain/header.cpp +++ b/test/chain/header.cpp @@ -56,6 +56,8 @@ class accessor } }; +static_assert(header::serialized_size() == 80_size); + // constructors // ---------------------------------------------------------------------------- From 13331fd095accd403aebfbaeed65a31f429ab52e Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sun, 21 Jul 2024 15:48:53 -0400 Subject: [PATCH 3/3] Comments, refactor to clean up from_data optimizations. --- include/bitcoin/system/chain/block.hpp | 2 +- include/bitcoin/system/chain/header.hpp | 1 - include/bitcoin/system/chain/input.hpp | 27 +++---- include/bitcoin/system/chain/operation.hpp | 28 ++----- include/bitcoin/system/chain/output.hpp | 1 - include/bitcoin/system/chain/point.hpp | 1 - include/bitcoin/system/chain/script.hpp | 5 +- include/bitcoin/system/chain/transaction.hpp | 4 +- include/bitcoin/system/chain/witness.hpp | 5 +- src/chain/block.cpp | 54 +------------ src/chain/header.cpp | 19 +---- src/chain/input.cpp | 13 +++ src/chain/operation.cpp | 23 ++++++ src/chain/output.cpp | 30 +------ src/chain/point.cpp | 15 +--- src/chain/script.cpp | 6 +- src/chain/transaction.cpp | 85 +------------------- src/chain/witness.cpp | 5 +- 18 files changed, 67 insertions(+), 257 deletions(-) diff --git a/include/bitcoin/system/chain/block.hpp b/include/bitcoin/system/chain/block.hpp index 55f637acae..fa086ed2f6 100644 --- a/include/bitcoin/system/chain/block.hpp +++ b/include/bitcoin/system/chain/block.hpp @@ -188,7 +188,7 @@ class BC_API block std::unordered_set; void assign_data(reader& source, bool witness) NOEXCEPT; - ////static block from_data(reader& source, bool witness) NOEXCEPT; + static block from_data(reader& source, bool witness) NOEXCEPT; static sizes serialized_size(const chain::transaction_cptrs& txs) NOEXCEPT; // context free diff --git a/include/bitcoin/system/chain/header.hpp b/include/bitcoin/system/chain/header.hpp index 99545c17f6..cc5a791d2e 100644 --- a/include/bitcoin/system/chain/header.hpp +++ b/include/bitcoin/system/chain/header.hpp @@ -140,7 +140,6 @@ class BC_API header private: void assign_data(reader& source) NOEXCEPT; - ////static header from_data(reader& source) NOEXCEPT; // Header should be stored as shared (adds 16 bytes). // copy: 4 * 32 + 2 * 256 + 1 = 81 bytes (vs. 16 when shared). diff --git a/include/bitcoin/system/chain/input.hpp b/include/bitcoin/system/chain/input.hpp index 24b9cae1dd..74396c96d1 100644 --- a/include/bitcoin/system/chain/input.hpp +++ b/include/bitcoin/system/chain/input.hpp @@ -124,31 +124,22 @@ class BC_API input bool valid) NOEXCEPT; private: - // So that witness may be set late in deserialization. - friend class transaction; - size_t nominal_size() const NOEXCEPT; - size_t witnessed_size() const NOEXCEPT; - void set_witness(reader& source) NOEXCEPT; - - inline const chain::witness& get_witness() const NOEXCEPT - { - return witness_ ? *witness_ : no_witness(); - } - - inline const chain::witness::cptr& get_witness_cptr() const NOEXCEPT - { - return witness_ ? witness_ : no_witness_cptr(); - } - typedef struct { size_t nominal; size_t witnessed; } sizes; - ////void assign_data(reader& source) NOEXCEPT; - ////static input from_data(reader& source) NOEXCEPT; static sizes serialized_size(const chain::script& script) NOEXCEPT; static sizes serialized_size(const chain::script& script, const chain::witness& witness) NOEXCEPT; static const chain::witness& no_witness() NOEXCEPT; static const chain::witness::cptr& no_witness_cptr() NOEXCEPT; + + // So that witness may be set late in deserialization. + friend class transaction; + size_t nominal_size() const NOEXCEPT; + size_t witnessed_size() const NOEXCEPT; + void set_witness(reader& source) NOEXCEPT; + + const chain::witness& get_witness() const NOEXCEPT; + const chain::witness::cptr& get_witness_cptr() const NOEXCEPT; bool extract_sigop_script(chain::script& out, const chain::script& prevout_script) const NOEXCEPT; diff --git a/include/bitcoin/system/chain/operation.hpp b/include/bitcoin/system/chain/operation.hpp index 5380626f95..a53783dedc 100644 --- a/include/bitcoin/system/chain/operation.hpp +++ b/include/bitcoin/system/chain/operation.hpp @@ -158,27 +158,6 @@ class BC_API operation friend class script; static bool count_op(reader& source) NOEXCEPT; - inline bool data_empty() const NOEXCEPT - { - return !data_ || data_->empty(); - } - - inline size_t data_size() const NOEXCEPT - { - return data_ ? data_->size() : zero; - } - - inline const data_chunk& get_data() const NOEXCEPT - { - return data_ ? *data_ : no_data(); - } - - inline const chunk_cptr& get_data_cptr() const NOEXCEPT - { - return data_ ? data_ : no_data_cptr(); - } - - void assign_data(reader& source) NOEXCEPT; static operation from_data(reader& source) NOEXCEPT; static operation from_push_data(const chunk_cptr& data, bool minimal) NOEXCEPT; @@ -190,7 +169,6 @@ class BC_API operation static const chunk_cptr& no_data_cptr() NOEXCEPT; static const chunk_cptr& any_data_cptr() NOEXCEPT; static uint32_t read_data_size(opcode code, reader& source) NOEXCEPT; - static inline opcode opcode_from_data(const data_chunk& push_data, bool minimal) NOEXCEPT { @@ -198,6 +176,12 @@ class BC_API operation nominal_opcode_from_data(push_data); } + bool data_empty() const NOEXCEPT; + size_t data_size() const NOEXCEPT; + const data_chunk& get_data() const NOEXCEPT; + const chunk_cptr& get_data_cptr() const NOEXCEPT; + void assign_data(reader& source) NOEXCEPT; + // Operation should not be stored as shared (adds 16 bytes). // copy: 8 + 2 * 64 + 1 = 18 bytes (vs. 16 when shared). opcode code_; diff --git a/include/bitcoin/system/chain/output.hpp b/include/bitcoin/system/chain/output.hpp index a9d1239cb5..70066a0894 100644 --- a/include/bitcoin/system/chain/output.hpp +++ b/include/bitcoin/system/chain/output.hpp @@ -96,7 +96,6 @@ class BC_API output private: void assign_data(reader& source) NOEXCEPT; - ////static output from_data(reader& source) NOEXCEPT; static size_t serialized_size(const chain::script& script, uint64_t value) NOEXCEPT; diff --git a/include/bitcoin/system/chain/point.hpp b/include/bitcoin/system/chain/point.hpp index e790b50937..0b6a18ca3e 100644 --- a/include/bitcoin/system/chain/point.hpp +++ b/include/bitcoin/system/chain/point.hpp @@ -94,7 +94,6 @@ class BC_API point private: void assign_data(reader& source) NOEXCEPT; - ////static point from_data(reader& source) NOEXCEPT; // The index is consensus-serialized as a fixed 4 bytes, however it is // effectively bound to 2^17 by the block byte size limit. diff --git a/include/bitcoin/system/chain/script.hpp b/include/bitcoin/system/chain/script.hpp index a4ad997ff3..df02df8389 100644 --- a/include/bitcoin/system/chain/script.hpp +++ b/include/bitcoin/system/chain/script.hpp @@ -172,9 +172,6 @@ class BC_API script size_t size) NOEXCEPT; private: - void assign_data(reader& source, bool prefix) NOEXCEPT; - ////static script from_data(reader& source, bool prefix) NOEXCEPT; - // TODO: move to config serialization wrapper. static script from_string(const std::string& mnemonic) NOEXCEPT; @@ -185,6 +182,8 @@ class BC_API script return ceilinged_add(total, op.serialized_size()); }; + void assign_data(reader& source, bool prefix) NOEXCEPT; + // Script should be stored as shared. operations ops_; diff --git a/include/bitcoin/system/chain/transaction.hpp b/include/bitcoin/system/chain/transaction.hpp index 16067ab9d7..a2c4bfe465 100644 --- a/include/bitcoin/system/chain/transaction.hpp +++ b/include/bitcoin/system/chain/transaction.hpp @@ -232,13 +232,13 @@ class BC_API transaction hash_digest sequences; } sighash_cache; - void assign_data(reader& source, bool witness) NOEXCEPT; - ////static transaction from_data(reader& source, bool witness) NOEXCEPT; static bool segregated(const chain::inputs& inputs) NOEXCEPT; static bool segregated(const chain::input_cptrs& inputs) NOEXCEPT; static sizes serialized_size(const chain::input_cptrs& inputs, const chain::output_cptrs& outputs, bool segregated) NOEXCEPT; + void assign_data(reader& source, bool witness) NOEXCEPT; + // signature hash hash_digest output_hash(const input_iterator& input) const NOEXCEPT; input_iterator input_at(uint32_t index) const NOEXCEPT; diff --git a/include/bitcoin/system/chain/witness.hpp b/include/bitcoin/system/chain/witness.hpp index 47d03ea63a..bacc407c64 100644 --- a/include/bitcoin/system/chain/witness.hpp +++ b/include/bitcoin/system/chain/witness.hpp @@ -124,9 +124,6 @@ class BC_API witness witness(const chunk_cptrs& stack, bool valid, size_t size) NOEXCEPT; private: - void assign_data(reader& source, bool prefix) NOEXCEPT; - ////static witness from_data(reader& source, bool prefix) NOEXCEPT; - // TODO: move to config serialization wrapper. static witness from_string(const std::string& mnemonic) NOEXCEPT; @@ -143,6 +140,8 @@ class BC_API witness BC_POP_WARNING() BC_POP_WARNING() + void assign_data(reader& source, bool prefix) NOEXCEPT; + // Witness should be stored as shared. chunk_cptrs stack_; diff --git a/src/chain/block.cpp b/src/chain/block.cpp index 3e220479df..15453cf690 100644 --- a/src/chain/block.cpp +++ b/src/chain/block.cpp @@ -44,6 +44,7 @@ namespace system { namespace chain { BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) +BC_PUSH_WARNING(NO_UNGUARDED_POINTERS) // Constructors. // ---------------------------------------------------------------------------- @@ -98,15 +99,11 @@ block::block(std::istream& stream, bool witness) NOEXCEPT } block::block(reader&& source, bool witness) NOEXCEPT - : block(source, witness/*from_data(source, witness)*/) + : block(source, witness) { } -// Initializing here prevents default initialization for header_/txs_, which -// would be redundant in light of later in-place initialization. This can be -// avoided altogether by not default-initializing, and moving to assign_data. block::block(reader& source, bool witness) NOEXCEPT -////: block(from_data(source, witness)) : header_( source.get_allocator().new_object(source), source.get_allocator().deleter(source.get_arena())), @@ -144,55 +141,10 @@ bool block::operator!=(const block& other) const NOEXCEPT // Deserialization. // ---------------------------------------------------------------------------- -////// static/private -////block block::from_data(reader& source, bool witness) NOEXCEPT -////{ -//// const auto read_transactions = [witness](reader& source) NOEXCEPT -//// { -//// // Allocate arena ctxs shared_ptr and std_vector(captures arena). -//// auto ctxs = to_allocated(source.get_arena()); -//// -//// BC_PUSH_WARNING(NO_UNGUARDED_POINTERS) -//// auto txs = to_non_const_raw_ptr(ctxs); -//// BC_POP_WARNING() -//// -//// // Allocate txs capacity(uses arena). -//// const auto capacity = source.read_size(max_block_size); -//// txs->reserve(capacity); -//// -//// // Allocate each shared_ptr and move ptr to reservation. -//// // Each tx is constructed in place as allocated by/with its pointer. -//// for (size_t tx = 0; tx < capacity; ++tx) -//// txs->push_back(to_allocated(source.get_arena(), -//// source, witness)); -//// -//// return ctxs; -//// }; -//// -//// // These two pointers are discarded on assignment to allocated block. -//// return -//// { -//// // Allocate header shared_ptr with header struct. -//// to_allocated(source.get_arena(), source), -//// read_transactions(source), -//// source -//// }; -////} - // private -BC_PUSH_WARNING(NO_UNGUARDED_POINTERS) void block::assign_data(reader& source, bool witness) NOEXCEPT { auto& allocator = source.get_allocator(); - - ////allocator.construct(&header_, - //// allocator.new_object(source), - //// allocator.deleter(source.get_arena())); - //// - ////allocator.construct(&txs_, - //// allocator.new_object(), - //// allocator.deleter(source.get_arena())); - const auto count = source.read_size(max_block_size); auto txs = to_non_const_raw_ptr(txs_); txs->reserve(count); @@ -205,7 +157,6 @@ void block::assign_data(reader& source, bool witness) NOEXCEPT size_ = serialized_size(*txs_); valid_ = source; } -BC_POP_WARNING() // Serialization. // ---------------------------------------------------------------------------- @@ -899,6 +850,7 @@ code block::connect(const context& ctx) const NOEXCEPT return connect_transactions(ctx); } +BC_POP_WARNING() BC_POP_WARNING() // JSON value convertors. diff --git a/src/chain/header.cpp b/src/chain/header.cpp index fbae38c7e8..f6f404be55 100644 --- a/src/chain/header.cpp +++ b/src/chain/header.cpp @@ -87,12 +87,11 @@ header::header(std::istream& stream) NOEXCEPT } header::header(reader&& source) NOEXCEPT - : header(source/*from_data(source)*/) + : header(source) { } header::header(reader& source) NOEXCEPT -////: header(from_data(source)) { assign_data(source); } @@ -146,23 +145,7 @@ bool header::operator!=(const header& other) const NOEXCEPT // Deserialization. // ---------------------------------------------------------------------------- -////// static/private -////header header::from_data(reader& source) NOEXCEPT -////{ -//// return -//// { -//// source.read_4_bytes_little_endian(), -//// source.read_hash(), -//// source.read_hash(), -//// source.read_4_bytes_little_endian(), -//// source.read_4_bytes_little_endian(), -//// source.read_4_bytes_little_endian(), -//// source -//// }; -////} - // private -// This denormalization eliminates allocation and copy of 64 bytes per block. void header::assign_data(reader& source) NOEXCEPT { // Hashes are copied directly into to header-allocated space. diff --git a/src/chain/input.cpp b/src/chain/input.cpp index d49f6992e2..fde50ed55b 100644 --- a/src/chain/input.cpp +++ b/src/chain/input.cpp @@ -42,6 +42,9 @@ static_assert(max_script_size < max_size_t / multisig_default_sigops / heavy_sigops_factor, "input sigop overflow guard"); +// Null witness helpers. +// ---------------------------------------------------------------------------- + // static/private const witness& input::no_witness() NOEXCEPT { @@ -61,6 +64,16 @@ const witness::cptr& input::no_witness_cptr() NOEXCEPT return empty; } +const chain::witness& input::get_witness() const NOEXCEPT +{ + return witness_ ? *witness_ : no_witness(); +} + +const chain::witness::cptr& input::get_witness_cptr() const NOEXCEPT +{ + return witness_ ? witness_ : no_witness_cptr(); +} + // Constructors. // ---------------------------------------------------------------------------- diff --git a/src/chain/operation.cpp b/src/chain/operation.cpp index d499dfde53..b2443cd1db 100644 --- a/src/chain/operation.cpp +++ b/src/chain/operation.cpp @@ -39,6 +39,9 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) // Gotta set something when invalid minimal result, test is_valid. static constexpr auto any_invalid = opcode::op_xor; +// Null data helpers. +// ---------------------------------------------------------------------------- + // static/private const data_chunk& operation::no_data() NOEXCEPT { @@ -71,6 +74,26 @@ const chunk_cptr& operation::any_data_cptr() NOEXCEPT return any; } +bool operation::data_empty() const NOEXCEPT +{ + return !data_ || data_->empty(); +} + +size_t operation::data_size() const NOEXCEPT +{ + return data_ ? data_->size() : zero; +} + +const data_chunk& operation::get_data() const NOEXCEPT +{ + return data_ ? *data_ : no_data(); +} + +const chunk_cptr& operation::get_data_cptr() const NOEXCEPT +{ + return data_ ? data_ : no_data_cptr(); +} + // Constructors. // ---------------------------------------------------------------------------- diff --git a/src/chain/output.cpp b/src/chain/output.cpp index e1c4b72a77..6d895278f8 100644 --- a/src/chain/output.cpp +++ b/src/chain/output.cpp @@ -86,12 +86,11 @@ output::output(std::istream& stream) NOEXCEPT } output::output(reader&& source) NOEXCEPT - : output(source/*from_data(source)*/) + : output(source) { } output::output(reader& source) NOEXCEPT -////: output(from_data(source)) : value_(source.read_8_bytes_little_endian()), script_( source.get_allocator().new_object(source, true), @@ -99,7 +98,6 @@ output::output(reader& source) NOEXCEPT valid_(source), size_(serialized_size(*script_, value_)) { - ////assign_data(source); } // protected @@ -129,32 +127,6 @@ bool output::operator!=(const output& other) const NOEXCEPT // Deserialization. // ---------------------------------------------------------------------------- -// static/private -////output output::from_data(reader& source) NOEXCEPT -////{ -//// return -//// { -//// source.read_8_bytes_little_endian(), -//// to_shared(source, true), -//// source -//// }; -////} - -// private -void output::assign_data(reader&) NOEXCEPT -{ - ////auto& allocator = source.get_allocator(); - //// - ////value_ = source.read_8_bytes_little_endian(); - //// - ////allocator.construct(&script_, - //// allocator.new_object(source, true), - //// allocator.deleter(source.get_arena())); - //// - ////size_ = serialized_size(*script_, value_); - ////valid_ = source; -} - // Serialization. // ---------------------------------------------------------------------------- diff --git a/src/chain/point.cpp b/src/chain/point.cpp index 1296f177af..bf96c0f3f9 100644 --- a/src/chain/point.cpp +++ b/src/chain/point.cpp @@ -79,12 +79,11 @@ point::point(std::istream& stream) NOEXCEPT } point::point(reader&& source) NOEXCEPT - : point(source/*from_data(source)*/) + : point(source) { } point::point(reader& source) NOEXCEPT -////: point(from_data(source)) { assign_data(source); } @@ -125,19 +124,7 @@ bool operator<(const point& left, const point& right) NOEXCEPT // Deserialization. // ---------------------------------------------------------------------------- -// static/private -////point point::from_data(reader& source) NOEXCEPT -////{ -//// return -//// { -//// source.read_hash(), -//// source.read_4_bytes_little_endian(), -//// source -//// }; -////} - // private -// This denormalization eliminates allocation and copy of 32 bytes per block. void point::assign_data(reader& source) NOEXCEPT { source.read_bytes(hash_.data(), hash_size); diff --git a/src/chain/script.cpp b/src/chain/script.cpp index 5a9ebe4e19..fdc26e69a8 100644 --- a/src/chain/script.cpp +++ b/src/chain/script.cpp @@ -138,12 +138,11 @@ script::script(std::istream& stream, bool prefix) NOEXCEPT } script::script(reader&& source, bool prefix) NOEXCEPT - : script(source, prefix/*from_data(source, prefix)*/) + : script(source, prefix) { } script::script(reader& source, bool prefix) NOEXCEPT -////: script(from_data(source, prefix)) : ops_(source.get_arena()) { assign_data(source, prefix); @@ -252,9 +251,6 @@ void script::assign_data(reader& source, bool prefix) NOEXCEPT source.set_limit(expected); } - ////auto& allocator = source.get_allocator(); - ////allocator.destroy(&ops_); - ////allocator.construct(&ops_); ops_.reserve(op_count(source)); const auto start = source.get_read_position(); diff --git a/src/chain/transaction.cpp b/src/chain/transaction.cpp index 6b935d4106..c8262ce78a 100644 --- a/src/chain/transaction.cpp +++ b/src/chain/transaction.cpp @@ -152,12 +152,11 @@ transaction::transaction(std::istream& stream, bool witness) NOEXCEPT } transaction::transaction(reader&& source, bool witness) NOEXCEPT - : transaction(source, witness/*from_data(source, witness)*/) + : transaction(source, witness) { } transaction::transaction(reader& source, bool witness) NOEXCEPT -////: transaction(from_data(source, witness)) : version_(source.read_4_bytes_little_endian()), inputs_( source.get_allocator().new_object(), @@ -236,93 +235,11 @@ bool transaction::operator!=(const transaction& other) const NOEXCEPT // Deserialization. // ---------------------------------------------------------------------------- -////template -////std::shared_ptr>> -////read_puts(Source& source) NOEXCEPT -////{ -//// // Allocate arena cputs shared_ptr and std_vector(captures arena). -//// using puts_type = std_vector>; -//// auto cputs = to_allocated(source.get_arena()); -//// -//// BC_PUSH_WARNING(NO_UNGUARDED_POINTERS) -//// auto puts = to_non_const_raw_ptr(cputs); -//// BC_POP_WARNING() -//// -//// // Allocate cputs capacity(uses arena). -//// const auto capacity = source.read_size(max_block_size); -//// puts->reserve(capacity); -//// -//// // Allocate each shared_ptr and move ptr to reservation. -//// // Each put is constructed in place as allocated by/with its pointer. -//// for (size_t put = 0; put < capacity; ++put) -//// puts->push_back(to_allocated(source.get_arena(), source)); -//// -//// return cputs; -////} -//// -////// static/private -////transaction transaction::from_data(reader& source, bool witness) NOEXCEPT -////{ -//// const auto version = source.read_4_bytes_little_endian(); -//// auto inputs = read_puts(source); -//// chain::outputs_cptr outputs; -//// -//// // Expensive repeated recomputation, so cache segregated state. -//// const auto segregated = inputs->size() == witness_marker && -//// source.peek_byte() == witness_enabled; -//// -//// // Detect witness as no inputs (marker) and expected flag (bip144). -//// if (segregated) -//// { -//// // Skip over the peeked witness flag. -//// source.skip_byte(); -//// -//// // Inputs and outputs are constructed on a vector of const pointers. -//// inputs = read_puts(source); -//// outputs = read_puts(source); -//// -//// // Read or skip witnesses as specified. -//// if (witness) -//// { -//// for (auto& input: *inputs) -//// { -//// BC_PUSH_WARNING(NO_UNGUARDED_POINTERS) -//// to_non_const_raw_ptr(input)->set_witness(source); -//// BC_POP_WARNING() -//// } -//// } -//// else -//// { -//// for (size_t in = 0; in < inputs->size(); ++in) -//// witness::skip(source, true); -//// } -//// } -//// else -//// { -//// // Default witness is populated on input construct. -//// outputs = read_puts(source); -//// } -//// -//// const auto locktime = source.read_4_bytes_little_endian(); -//// return { version, inputs, outputs, locktime, segregated, source }; -////} - // private BC_PUSH_WARNING(NO_UNGUARDED_POINTERS) void transaction::assign_data(reader& source, bool witness) NOEXCEPT { auto& allocator = source.get_allocator(); - - ////allocator.construct(&inputs_, - //// allocator.new_object(), - //// allocator.deleter(source.get_arena())); - //// - ////allocator.construct(&outputs_, - //// allocator.new_object(), - //// allocator.deleter(source.get_arena())); - //// - ////version_ = source.read_4_bytes_little_endian(); - auto ins = to_non_const_raw_ptr(inputs_); auto count = source.read_size(max_block_size); ins->reserve(count); diff --git a/src/chain/witness.cpp b/src/chain/witness.cpp index 8cf5f47a31..03c96dbd98 100644 --- a/src/chain/witness.cpp +++ b/src/chain/witness.cpp @@ -98,12 +98,11 @@ witness::witness(std::istream& stream, bool prefix) NOEXCEPT } witness::witness(reader&& source, bool prefix) NOEXCEPT - : witness(source, prefix/*from_data(source, prefix)*/) + : witness(source, prefix) { } witness::witness(reader& source, bool prefix) NOEXCEPT -////: witness(from_data(source, prefix)) : stack_(source.get_arena()) { assign_data(source, prefix); @@ -169,8 +168,6 @@ void witness::assign_data(reader& source, bool prefix) NOEXCEPT { size_ = zero; const auto& allocator = source.get_allocator(); - ////allocator.destroy(&stack_); - ////allocator.construct(&stack_); if (prefix) {