how to call private fields in eosio (c++)

79 views Asked by At

I have two versions of response in eosio :

v. 1.8.1

block_state::block_state( pending_block_header_state&& cur,
                             const signed_block_ptr& b,
                             vector<transaction_metadata_ptr>&& trx_metas,
                             const std::function<void( block_timestamp_type,
                                                       const flat_set<digest_type>&,
                                                       const vector<digest_type>& )>& validator,
                             bool skip_validate_signee
                           )
   :block_header_state( std::move(cur).finish_next( *b, validator, skip_validate_signee ) )
   ,block( b )
   ,trxs( std::move(trx_metas) ) <-----
   {}

v. 2.0.11

block_state::block_state( pending_block_header_state&& cur,
                             signed_block_ptr&& b,
                             vector<transaction_metadata_ptr>&& trx_metas,
                             const protocol_feature_set& pfs,
                             const std::function<void( block_timestamp_type,
                                                       const flat_set<digest_type>&,
                                                       const vector<digest_type>& )>& validator,
                             const signer_callback_type& signer
                           )
   :block_header_state( inject_additional_signatures( std::move(cur), *b, pfs, validator, signer ) )
   ,block( std::move(b) )
   ,_pub_keys_recovered( true ) // called by produce_block so signature recovery of trxs must have been done
   ,_cached_trxs( std::move(trx_metas) ) <-----
   {}

it works fine with first version :

for (const auto &transaction : block->trxs)
{  }

but when i want call similarly in second :

for (const auto &transaction : block->_cached_trxs)
{  }

I have an error :

_cached_trxs is a private member of 'eosio::chain::block_state'

How can i resolve this issue?

UPD: Added source link src

1

There are 1 answers

0
Jacob On

My C++ is a bit rusty, but it looks like you can access it using the extract_trx_metas method of the pending_state object.

eos/libraries/chain/controller.cpp line 101