Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
block_state.cpp
Go to the documentation of this file.
3
4namespace sysio { namespace chain {
5
6 namespace {
7 constexpr auto additional_sigs_eid = additional_block_signatures_extension::extension_id();
8
18 vector<signature_type> extract_additional_signatures( const signed_block_ptr& b,
19 const protocol_feature_set& pfs,
21 {
22 auto exts = b->validate_and_extract_extensions();
23
24 if ( exts.count(additional_sigs_eid) > 0 ) {
25 auto& additional_sigs = std::get<additional_block_signatures_extension>(exts.lower_bound(additional_sigs_eid)->second);
26
27 return std::move(additional_sigs.signatures);
28 }
29
30 return {};
31 }
32
49 template<typename ...Extras>
50 block_header_state inject_additional_signatures( pending_block_header_state&& cur,
51 signed_block& b,
52 const protocol_feature_set& pfs,
53 Extras&& ... extras )
54 {
55 auto pfa = cur.prev_activated_protocol_features;
56 block_header_state result = std::move(cur).finish_next(b, pfs, std::forward<Extras>(extras)...);
57
58 if (!result.additional_signatures.empty()) {
60
62 "Block has multiple signatures before activation of WTMsig Block Signatures");
63
64 // as an optimization we don't copy this out into the legitimate extension structure as it serializes
65 // the same way as the vector of signatures
67 static_assert(std::is_same_v<decltype(additional_block_signatures_extension::signatures), std::vector<signature_type>>);
68
69 emplace_extension(b.block_extensions, additional_sigs_eid, fc::raw::pack( result.additional_signatures ));
70 }
71
72 return result;
73 }
74
75 }
76
79 const protocol_feature_set& pfs,
80 const std::function<void( block_timestamp_type,
81 const flat_set<digest_type>&,
82 const vector<digest_type>& )>& validator,
83 bool skip_validate_signee
84 )
85 :block_header_state( prev.next( *b, extract_additional_signatures(b, pfs, prev.activated_protocol_features), pfs, validator, skip_validate_signee ) )
86 ,block( std::move(b) )
87 {}
88
92 const protocol_feature_set& pfs,
93 const std::function<void( block_timestamp_type,
94 const flat_set<digest_type>&,
95 const vector<digest_type>& )>& validator,
96 const signer_callback_type& signer
97 )
98 :block_header_state( inject_additional_signatures( std::move(cur), *b, pfs, validator, signer ) )
99 ,block( std::move(b) )
100 ,_pub_keys_recovered( true ) // called by produce_block so signature recovery of trxs must have been done
101 ,_cached_trxs( std::move(trx_metas) )
102 {}
103
104} }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
Definition name.hpp:106
bool is_builtin_activated(const protocol_feature_activation_set_ptr &pfa, const protocol_feature_set &pfs, builtin_protocol_feature_t feature_codename)
std::function< std::vector< signature_type >(const digest_type &)> signer_callback_type
auto emplace_extension(extensions_type &exts, uint16_t eid, vector< char > &&data)
Definition types.hpp:264
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found block_validate_exception
std::shared_ptr< signed_block > signed_block_ptr
Definition block.hpp:105
std::shared_ptr< protocol_feature_activation_set > protocol_feature_activation_set_ptr
defines visit functions for T Unless this is specialized, visit() will not be defined for T.
Definition reflect.hpp:33
defines the minimum state necessary to validate transaction headers