Skip to content

Commit

Permalink
GH-8 Add assert that extensions are sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Apr 24, 2024
1 parent 96e2f68 commit e6b8d8b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libraries/chain/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace eosio::chain {
std::optional<block_extension> signed_block::extract_extension(uint16_t extension_id)const {
using decompose_t = block_extension_types::decompose_t;

assert(std::ranges::is_sorted(block_extensions)); // currently all extensions are unique so default compare works

for( size_t i = 0; i < block_extensions.size(); ++i ) {
const auto& e = block_extensions[i];
auto id = e.first;
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/block_header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace eosio { namespace chain {
std::optional<block_header_extension> block_header::extract_header_extension(uint16_t extension_id)const {
using decompose_t = block_header_extension_types::decompose_t;

assert(std::ranges::is_sorted(header_extensions)); // currently all extensions are unique so default compare works

for( size_t i = 0; i < header_extensions.size(); ++i ) {
const auto& e = header_extensions[i];
auto id = e.first;
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/eosio/chain/block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ namespace eosio { namespace chain {
}

using block_extension_types = detail::block_extension_types<
additional_block_signatures_extension, quorum_certificate_extension
additional_block_signatures_extension,
quorum_certificate_extension
>;

using block_extension = block_extension_types::block_extension_t;
Expand Down

0 comments on commit e6b8d8b

Please sign in to comment.