Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions include/bitcoin/system/chain/stripper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef LIBBITCOIN_SYSTEM_CHAIN_STRIPPER_HPP
#define LIBBITCOIN_SYSTEM_CHAIN_STRIPPER_HPP

#include <bitcoin/system/chain/enums/magic_numbers.hpp>
#include <bitcoin/system/chain/operation.hpp>
#include <bitcoin/system/data/data.hpp>
#include <bitcoin/system/define.hpp>
Expand All @@ -35,15 +34,6 @@ namespace chain {
class BC_API stripper final
{
public:
using span = std::span<const stripper>;
using buffer = std::array<stripper, add1(max_multisig_public_keys)>;

/// Fills a stack allocation with opcode::codeseparator.
inline stripper() NOEXCEPT
: code_(opcode::codeseparator), data_()
{
}

// ************************************************************************
// CONSENSUS: nominal endorsement operation encoding is required.
// ************************************************************************
Expand Down Expand Up @@ -84,6 +74,8 @@ inline bool operator==(const operation& op, const stripper& strip) NOEXCEPT
return op.code() == strip.code() && op.data() == strip.data();
}

typedef std::vector<stripper> strippers;

} // namespace chain
} // namespace system
} // namespace libbitcoin
Expand Down
31 changes: 13 additions & 18 deletions include/bitcoin/system/impl/machine/program_verify.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,25 @@ set_subscript(const op_iterator& op) NOEXCEPT

// static/private
TEMPLATE
inline chain::stripper::span CLASS::
create_strip_ops(chain::stripper::buffer& out,
const chunk_xptrs& endorsements) NOEXCEPT
inline chain::strippers CLASS::
create_strip_ops(const chunk_xptrs& endorsements) NOEXCEPT
{
BC_ASSERT(endorsements.size() < out.size());
auto it = out.begin();
chain::strippers strip{};
strip.reserve(add1(endorsements.size()));
for (const auto& endorsement: endorsements)
*it++ = chain::stripper{ endorsement };
strip.emplace_back(endorsement);

*it++ = chain::stripper{ chain::opcode::codeseparator };
return { out.begin(), it };
strip.emplace_back(chain::opcode::codeseparator);
return strip;
}

// static/private
TEMPLATE
inline chain::stripper::span CLASS::
create_strip_ops(chain::stripper::buffer& out,
const chunk_xptr& endorsement) NOEXCEPT
inline chain::strippers CLASS::
create_strip_ops(const chunk_xptr& endorsement) NOEXCEPT
{
out.front() = chain::stripper{ endorsement };
out.at(one) = chain::stripper{ chain::opcode::codeseparator };
return { out.begin(), two };
using namespace chain;
return { stripper{ endorsement }, stripper{ opcode::codeseparator } };
}

// ****************************************************************************
Expand All @@ -176,8 +173,7 @@ subscript(const chunk_xptrs& endorsements) const NOEXCEPT
return script_;

// Transform into a set of endorsement push ops and one op_codeseparator.
chain::stripper::buffer buffer{};
const auto strip = create_strip_ops(buffer, endorsements);
const auto strip = create_strip_ops(endorsements);
const auto stop = script_->ops().end();
const op_iterator start{ script_->offset };

Expand All @@ -199,8 +195,7 @@ subscript(const chunk_xptr& endorsement) const NOEXCEPT
return script_;

// Transform into a set with one endorsement push op and op_codeseparator.
chain::stripper::buffer buffer{};
const auto strip = create_strip_ops(buffer, endorsement);
const auto strip = create_strip_ops(endorsement);
const auto stop = script_->ops().end();
const op_iterator start{ script_->offset };

Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/system/machine/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ class program

// Verify helpers.
static inline bool is_schnorr_sighash(uint8_t sighash_flags) NOEXCEPT;
static inline chain::stripper::span create_strip_ops(
chain::stripper::buffer& out, const chunk_xptrs& endorsements) NOEXCEPT;
static inline chain::stripper::span create_strip_ops(
chain::stripper::buffer& out, const chunk_xptr& endorsement) NOEXCEPT;
static inline chain::strippers create_strip_ops(
const chunk_xptrs& endorsements) NOEXCEPT;
static inline chain::strippers create_strip_ops(
const chunk_xptr& endorsement) NOEXCEPT;

// Batching helpers.
inline bool parse_ecdsa_multisig(hash_digest& hash, keys_array& keys,
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/system/warnings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#define NO_DYNAMIC_ARRAY_INDEXING 26482
#define NO_ARRAY_TO_POINTER_DECAY 26485
#define NO_REINTERPRET_CAST 26490
#define NO_STATIC_DOWNCASTS 26491
#define NO_CONST_CAST 26492
#define NO_C_STYLE_CASTS 26493
#define NO_UNINITIALZIED_VARIABLE 26494
Expand Down
Loading