Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
protocol_feature_activation.cpp
Go to the documentation of this file.
3
4#include <algorithm>
5
6namespace sysio { namespace chain {
7
10 "protocol_feature_activation expects FC to support reflector_init" );
11
12
13 SYS_ASSERT( protocol_features.size() > 0, ill_formed_protocol_feature_activation,
14 "Protocol feature activation extension must have at least one protocol feature digest",
15 );
16
17 set<digest_type> s;
18
19 for( const auto& d : protocol_features ) {
20 auto res = s.insert( d );
21 SYS_ASSERT( res.second, ill_formed_protocol_feature_activation,
22 "Protocol feature digest ${d} was repeated in the protocol feature activation extension",
23 ("d", d)
24 );
25 }
26 }
27
29 const protocol_feature_activation_set& orig_pfa_set,
30 vector<digest_type> additional_features,
31 bool enforce_disjoint
32 )
33 {
34 std::sort( additional_features.begin(), additional_features.end() );
35
36 const auto& s1 = orig_pfa_set.protocol_features;
37 const auto& s2 = additional_features;
38
39 auto expected_size = s1.size() + s2.size();
40 protocol_features.reserve( expected_size );
41
42 std::set_union( s1.cbegin(), s1.cend(), s2.cbegin(), s2.cend(), end_inserter( protocol_features ) );
43
44 SYS_ASSERT( !enforce_disjoint || protocol_features.size() == expected_size,
45 invalid_block_header_extension,
46 "duplication of protocol feature digests"
47 );
48 }
49
50} } // sysio::chain
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
constexpr bool has_feature_reflector_init_on_unpacked_reflected_types
Definition raw.hpp:440
end_insert_iterator< Container > end_inserter(Container &c)
Definition types.hpp:303
CK_ULONG d
char * s