Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::pending_state Struct Reference
Collaboration diagram for sysio::chain::pending_state:

Public Member Functions

 pending_state (maybe_session &&s, const block_header_state &prev, block_timestamp_type when, uint16_t num_prev_blocks_to_confirm, const vector< digest_type > &new_protocol_feature_activations)
 
const pending_block_header_stateget_pending_block_header_state () const
 
const vector< transaction_receipt > & get_trx_receipts () const
 
vector< transaction_metadata_ptrextract_trx_metas ()
 
bool is_protocol_feature_activated (const digest_type &feature_digest) const
 
void push ()
 

Public Attributes

maybe_session _db_session
 
block_stage_type _block_stage
 
controller::block_status _block_status = controller::block_status::incomplete
 
std::optional< block_id_type_producer_block_id
 

Detailed Description

Definition at line 147 of file controller.cpp.

Constructor & Destructor Documentation

◆ pending_state()

sysio::chain::pending_state::pending_state ( maybe_session && s,
const block_header_state & prev,
block_timestamp_type when,
uint16_t num_prev_blocks_to_confirm,
const vector< digest_type > & new_protocol_feature_activations )
inline

Definition at line 148 of file controller.cpp.

152 :_db_session( move(s) )
153 ,_block_stage( building_block( prev, when, num_prev_blocks_to_confirm, new_protocol_feature_activations ) )
154 {}
block_stage_type _block_stage
char * s

Member Function Documentation

◆ extract_trx_metas()

vector< transaction_metadata_ptr > sysio::chain::pending_state::extract_trx_metas ( )
inline

Definition at line 179 of file controller.cpp.

179 {
180 if( std::holds_alternative<building_block>(_block_stage) )
181 return std::move( std::get<building_block>(_block_stage)._pending_trx_metas );
182
183 if( std::holds_alternative<assembled_block>(_block_stage) )
184 return std::move( std::get<assembled_block>(_block_stage)._trx_metas );
185
186 return std::get<completed_block>(_block_stage)._block_state->extract_trxs_metas();
187 }

◆ get_pending_block_header_state()

const pending_block_header_state & sysio::chain::pending_state::get_pending_block_header_state ( ) const
inline
Precondition
_block_stage cannot hold completed_block alternative

Definition at line 162 of file controller.cpp.

162 {
163 if( std::holds_alternative<building_block>(_block_stage) )
164 return std::get<building_block>(_block_stage)._pending_block_header_state;
165
166 return std::get<assembled_block>(_block_stage)._pending_block_header_state;
167 }

◆ get_trx_receipts()

const vector< transaction_receipt > & sysio::chain::pending_state::get_trx_receipts ( ) const
inline

Definition at line 169 of file controller.cpp.

169 {
170 if( std::holds_alternative<building_block>(_block_stage) )
171 return std::get<building_block>(_block_stage)._pending_trx_receipts;
172
173 if( std::holds_alternative<assembled_block>(_block_stage) )
174 return std::get<assembled_block>(_block_stage)._unsigned_block->transactions;
175
176 return std::get<completed_block>(_block_stage)._block_state->block->transactions;
177 }

◆ is_protocol_feature_activated()

bool sysio::chain::pending_state::is_protocol_feature_activated ( const digest_type & feature_digest) const
inline

Definition at line 189 of file controller.cpp.

189 {
190 if( std::holds_alternative<building_block>(_block_stage) ) {
191 auto& bb = std::get<building_block>(_block_stage);
192 const auto& activated_features = bb._pending_block_header_state.prev_activated_protocol_features->protocol_features;
193
194 if( activated_features.find( feature_digest ) != activated_features.end() ) return true;
195
196 if( bb._num_new_protocol_features_that_have_activated == 0 ) return false;
197
198 auto end = bb._new_protocol_feature_activations.begin() + bb._num_new_protocol_features_that_have_activated;
199 return (std::find( bb._new_protocol_feature_activations.begin(), end, feature_digest ) != end);
200 }
201
202 if( std::holds_alternative<assembled_block>(_block_stage) ) {
203 // Calling is_protocol_feature_activated during the assembled_block stage is not efficient.
204 // We should avoid doing it.
205 // In fact for now it isn't even implemented.
206 SYS_THROW( misc_exception,
207 "checking if protocol feature is activated in the assembled_block stage is not yet supported" );
208 // TODO: implement this
209 }
210
211 const auto& activated_features = std::get<completed_block>(_block_stage)._block_state->activated_protocol_features->protocol_features;
212 return (activated_features.find( feature_digest ) != activated_features.end());
213 }
#define SYS_THROW(exc_type, FORMAT,...)

◆ push()

void sysio::chain::pending_state::push ( )
inline

Definition at line 215 of file controller.cpp.

215 {
217 }
Here is the call graph for this function:

Member Data Documentation

◆ _block_stage

block_stage_type sysio::chain::pending_state::_block_stage

Definition at line 157 of file controller.cpp.

◆ _block_status

controller::block_status sysio::chain::pending_state::_block_status = controller::block_status::incomplete

Definition at line 158 of file controller.cpp.

◆ _db_session

maybe_session sysio::chain::pending_state::_db_session

Definition at line 156 of file controller.cpp.

◆ _producer_block_id

std::optional<block_id_type> sysio::chain::pending_state::_producer_block_id

Definition at line 159 of file controller.cpp.


The documentation for this struct was generated from the following file: