Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain_apis::trx_retry_db_impl Struct Reference

Public Member Functions

 trx_retry_db_impl (const chain::controller &controller, size_t max_mem_usage_size, fc::microseconds retry_interval, fc::microseconds max_expiration_time, fc::microseconds abi_serializer_max_time)
 
const fc::microsecondsget_max_expiration () const
 
size_t size () const
 
void track_transaction (packed_transaction_ptr ptrx, std::optional< uint16_t > num_blocks, next_function< std::unique_ptr< fc::variant > > next)
 
void on_applied_transaction (const chain::transaction_trace_ptr &trace, const chain::packed_transaction_ptr &ptrx)
 
void on_block_start (uint32_t block_num)
 
void on_accepted_block (const chain::block_state_ptr &bsp)
 
void on_irreversible_block (const chain::block_state_ptr &bsp)
 

Detailed Description

Definition at line 92 of file trx_retry_db.cpp.

Constructor & Destructor Documentation

◆ trx_retry_db_impl()

sysio::chain_apis::trx_retry_db_impl::trx_retry_db_impl ( const chain::controller & controller,
size_t max_mem_usage_size,
fc::microseconds retry_interval,
fc::microseconds max_expiration_time,
fc::microseconds abi_serializer_max_time )
inlineexplicit

Definition at line 93 of file trx_retry_db.cpp.

96 : _controller(controller)
97 , _transaction_ack_channel(appbase::app().get_channel<chain::plugin_interface::compat::channels::transaction_ack>())
98 , _abi_serializer_max_time(abi_serializer_max_time)
99 , _max_mem_usage_size(max_mem_usage_size)
100 , _retry_interval(retry_interval)
101 , _max_expiration_time(max_expiration_time)
102 {}
application & app()
const fc::microseconds abi_serializer_max_time
Definition main.cpp:173

Member Function Documentation

◆ get_max_expiration()

const fc::microseconds & sysio::chain_apis::trx_retry_db_impl::get_max_expiration ( ) const
inline

Definition at line 104 of file trx_retry_db.cpp.

104 {
105 return _max_expiration_time;
106 }

◆ on_accepted_block()

void sysio::chain_apis::trx_retry_db_impl::on_accepted_block ( const chain::block_state_ptr & bsp)
inline

Definition at line 166 of file trx_retry_db.cpp.

166 {
167 // good time to perform processing
168 ack_ready_trxs_by_block_num( bsp->block_num );
169 retry_trxs();
170 }

◆ on_applied_transaction()

void sysio::chain_apis::trx_retry_db_impl::on_applied_transaction ( const chain::transaction_trace_ptr & trace,
const chain::packed_transaction_ptr & ptrx )
inline

Definition at line 128 of file trx_retry_db.cpp.

128 {
129 if( !trace->receipt ) return;
130 // include only executed incoming transactions.
131 // soft_fail not included as only interested in incoming
132 if(trace->receipt->status != chain::transaction_receipt_header::executed) {
133 return;
134 }
135 // only incoming
136 if( trace->scheduled ) return;
137 // Only want transactions in a block, if no producer id then not in a block
138 if( !trace->producer_block_id ) return;
139 // Don't care about implicit
140 if( chain::is_onblock( *trace ) ) return;
141
142 // Is this a transaction we are tracking
143 auto& idx = _tracked_trxs.index().get<by_trx_id>();
144 auto itr = idx.find(trace->id);
145 if( itr != idx.end() ) {
146 _tracked_trxs.modify( itr, [&trace, &control=_controller, &abi_max_time=_abi_serializer_max_time]( tracked_transaction& tt ) {
147 tt.block_num = trace->block_num;
148 try {
149 // send_transaction trace output format.
150 // Convert to variant with abi here and now because abi could change in very next transaction.
151 // Alternatively, we could store off all the abis needed and do the conversion later, but as this is designed
152 // to run on an API node, probably the best trade off to perform the abi serialization during block processing.
153 tt.trx_trace_v = control.to_variant_with_abi( *trace, abi_serializer::create_yield_function( abi_max_time ) );
154 } catch( chain::abi_exception& ) {
155 tt.trx_trace_v = *trace;
156 }
157 } );
158 }
159 }
void modify(typename primary_index_type::iterator itr, Lam lam)
const ContainerType & index() const
bool is_onblock(const transaction_trace &tt)
Definition trace.hpp:71
static yield_function_t create_yield_function(const fc::microseconds &max_serialization_time)
@ executed
succeed, no error handler executed
Definition block.hpp:14
Here is the call graph for this function:

◆ on_block_start()

void sysio::chain_apis::trx_retry_db_impl::on_block_start ( uint32_t block_num)
inline

Definition at line 161 of file trx_retry_db.cpp.

161 {
162 // on forks rollback any accepted block transactions
163 rollback_to( block_num );
164 }

◆ on_irreversible_block()

void sysio::chain_apis::trx_retry_db_impl::on_irreversible_block ( const chain::block_state_ptr & bsp)
inline

Definition at line 172 of file trx_retry_db.cpp.

172 {
173 ack_ready_trxs_by_lib( bsp->block_num );
174 clear_expired( bsp->block->timestamp );
175 }

◆ size()

size_t sysio::chain_apis::trx_retry_db_impl::size ( ) const
inline

Definition at line 108 of file trx_retry_db.cpp.

108 {
109 return _tracked_trxs.index().size();
110 }
Here is the call graph for this function:

◆ track_transaction()

void sysio::chain_apis::trx_retry_db_impl::track_transaction ( packed_transaction_ptr ptrx,
std::optional< uint16_t > num_blocks,
next_function< std::unique_ptr< fc::variant > > next )
inline

Definition at line 112 of file trx_retry_db.cpp.

112 {
113 SYS_ASSERT( _tracked_trxs.memory_size() < _max_mem_usage_size, tx_resource_exhaustion,
114 "Transaction exceeded transaction-retry-max-storage-size-gb limit: ${m} bytes", ("m", _tracked_trxs.memory_size()) );
115 auto i = _tracked_trxs.index().get<by_trx_id>().find( ptrx->id() );
116 if( i == _tracked_trxs.index().end() ) {
117 _tracked_trxs.insert( {std::move(ptrx),
118 !num_blocks.has_value() ? lib_totem : *num_blocks,
119 0,
120 {},
122 std::move(next)} );
123 } else {
124 // already tracking transaction
125 }
126 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
static time_point now()
Definition time.cpp:14
size_t memory_size() const
std::pair< typename primary_index_type::iterator, bool > insert(typename ContainerType::value_type obj)
RUNTIME_API Runtime::ObjectInstance * find(const std::string &name, const IR::ObjectType &type)
Here is the call graph for this function:

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