Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::trace_api::request_handler< LogfileProvider, DataHandlerProvider > Class Template Reference

#include <request_handler.hpp>

Public Member Functions

 request_handler (LogfileProvider &&logfile_provider, DataHandlerProvider &&data_handler_provider, log_handler log)
 
fc::variant get_block_trace (uint32_t block_height, const yield_function &yield={})
 
fc::variant get_transaction_trace (chain::transaction_id_type trxid, uint32_t block_height, const yield_function &yield={})
 

Detailed Description

template<typename LogfileProvider, typename DataHandlerProvider>
class sysio::trace_api::request_handler< LogfileProvider, DataHandlerProvider >

Definition at line 19 of file request_handler.hpp.

Constructor & Destructor Documentation

◆ request_handler()

template<typename LogfileProvider , typename DataHandlerProvider >
sysio::trace_api::request_handler< LogfileProvider, DataHandlerProvider >::request_handler ( LogfileProvider && logfile_provider,
DataHandlerProvider && data_handler_provider,
log_handler log )
inline

Definition at line 21 of file request_handler.hpp.

22 :logfile_provider(std::move(logfile_provider))
23 ,data_handler_provider(std::move(data_handler_provider))
24 ,_log(log)
25 {
26 _log("Constructed request_handler");
27 }

Member Function Documentation

◆ get_block_trace()

template<typename LogfileProvider , typename DataHandlerProvider >
fc::variant sysio::trace_api::request_handler< LogfileProvider, DataHandlerProvider >::get_block_trace ( uint32_t block_height,
const yield_function & yield = {} )
inline

Fetch the trace for a given block height and convert it to a fc::variant for conversion to a final format (eg JSON)

Parameters
block_height- the height of the block whose trace is requested
yield- a yield function to allow cooperation during long running tasks
Returns
a properly formatted variant representing the trace for the given block height if it exists, an empty variant otherwise.
Exceptions
yield_exceptionif a call to yield throws.
bad_data_exceptionwhen there are issues with the underlying data preventing processing.

Definition at line 40 of file request_handler.hpp.

40 {}) {
41 auto data = logfile_provider.get_block(block_height, yield);
42 if (!data) {
43 _log("No block found at block height " + std::to_string(block_height) );
44 return {};
45 }
46
47 yield();
48
49 auto data_handler = [this](const auto& action, const yield_function& yield) -> std::tuple<fc::variant, std::optional<fc::variant>> {
50 return std::visit([&](const auto& action_trace_t) {
51 return data_handler_provider.serialize_to_variant(action_trace_t, yield);
52 }, action);
53 };
54
55 return detail::response_formatter::process_block(std::get<0>(*data), std::get<1>(*data), data_handler, yield);
56 }
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
static fc::variant process_block(const data_log_entry &trace, bool irreversible, const data_handler_function &data_handler, const yield_function &yield)
thread_local yield_t yield
Definition yield.hpp:52
fc::optional_delegate< void()> yield_function
Definition common.hpp:13

◆ get_transaction_trace()

template<typename LogfileProvider , typename DataHandlerProvider >
fc::variant sysio::trace_api::request_handler< LogfileProvider, DataHandlerProvider >::get_transaction_trace ( chain::transaction_id_type trxid,
uint32_t block_height,
const yield_function & yield = {} )
inline

Fetch the trace for a given transaction id and convert it to a fc::variant for conversion to a final format (eg JSON)

Parameters
trxid- the transaction id whose trace is requested
block_height- the height of the block whose trace contains requested transaction trace
yield- a yield function to allow cooperation during long running tasks
Returns
a properly formatted variant representing the trace for the given transaction id if it exists, an empty variant otherwise.
Exceptions
yield_exceptionif a call to yield throws.
bad_data_exceptionwhen there are issues with the underlying data preventing processing.

Definition at line 70 of file request_handler.hpp.

70 {}){
71 _log("get_transaction_trace called" );
72 fc::variant result = {};
73 // extract the transaction trace from the block trace
74 auto resp = get_block_trace(block_height, yield);
75 if (!resp.is_null()) {
76 auto& b_mvo = resp.get_object();
77 if (b_mvo.contains("transactions")) {
78 auto& transactions = b_mvo["transactions"];
79 std::string input_id = trxid.str();
80 for (uint32_t i = 0; i < transactions.size(); ++i) {
81 if (transactions[i].is_null()) continue;
82 auto& t_mvo = transactions[i].get_object();
83 if (t_mvo.contains("id")) {
84 const auto& t_id = t_mvo["id"].get_string();
85 if (t_id == input_id) {
86 result = transactions[i];
87 break;
88 }
89 }
90 }
91 if( result.is_null() )
92 _log("Exhausted all " + std::to_string(transactions.size()) + " transactions in block " + b_mvo["number"].as_string() + " without finding trxid " + trxid.str());
93 }
94 }
95 return result;
96 }
fc::variant get_block_trace(uint32_t block_height, const yield_function &yield={})
unsigned int uint32_t
Definition stdint.h:126

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