Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
extract_util.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace sysio { namespace trace_api {
7
9template<typename ActionTrace>
10inline ActionTrace to_action_trace( const chain::action_trace& at ) {
11 ActionTrace r;
12 r.receiver = at.receiver;
13 r.account = at.act.account;
14 r.action = at.act.name;
15 r.data = at.act.data;
16 if constexpr(std::is_same_v<ActionTrace, action_trace_v1>) {
17 r.return_value = at.return_value;
18 }
19 if( at.receipt ) {
20 r.global_sequence = at.receipt->global_sequence;
21 }
22 r.authorization.reserve( at.act.authorization.size());
23 for( const auto& auth : at.act.authorization ) {
24 r.authorization.emplace_back( authorization_trace_v0{auth.actor, auth.permission} );
25 }
26 return r;
27}
28
29template<typename TransactionTrace>
30inline TransactionTrace to_transaction_trace( const cache_trace& t ) {
31 TransactionTrace r;
32 if( !t.trace->failed_dtrx_trace ) {
33 r.id = t.trace->id;
34 } else {
35 r.id = t.trace->failed_dtrx_trace->id; // report the failed trx id since that is the id known to user
36 }
37 if constexpr(std::is_same_v<TransactionTrace, transaction_trace_v1> ||
38 std::is_same_v<TransactionTrace, transaction_trace_v2> ||
39 std::is_same_v<TransactionTrace, transaction_trace_v3>) {
40 if (t.trace->receipt) {
41 r.status = t.trace->receipt->status;
42 r.cpu_usage_us = t.trace->receipt->cpu_usage_us;
43 r.net_usage_words = t.trace->receipt->net_usage_words;
44 }
45 r.signatures = t.trx->get_signatures();
46 r.trx_header = static_cast<const chain::transaction_header&>( t.trx->get_transaction() );
47
48 r.block_num = t.trace->block_num;
49 r.block_time = t.trace->block_time;
50 r.producer_block_id = t.trace->producer_block_id;
51 }
52
53 using action_trace_t = std::conditional_t<std::is_same_v<TransactionTrace, transaction_trace_v2> ||
54 std::is_same_v<TransactionTrace, transaction_trace_v3>
56 r.actions = std::vector<action_trace_t>();
57 std::get<std::vector<action_trace_t>>(r.actions).reserve( t.trace->action_traces.size());
58 for( const auto& at : t.trace->action_traces ) {
59 if( !at.context_free ) { // not including CFA at this time
60 std::get<std::vector<action_trace_t>>(r.actions).emplace_back( to_action_trace<action_trace_t>(at) );
61 }
62 }
63 return r;
64}
65
68 r.id = bsp->id;
69 r.number = bsp->block_num;
70 r.previous_id = bsp->block->previous;
71 r.timestamp = bsp->block->timestamp;
72 r.producer = bsp->block->producer;
73 r.schedule_version = bsp->block->schedule_version;
74 r.transaction_mroot = bsp->block->transaction_mroot;
75 r.action_mroot = bsp->block->action_mroot;
76 return r;
77}
78
79} }
const mie::Vuint & r
Definition bn.cpp:28
std::shared_ptr< block_state > block_state_ptr
block_trace_v2 create_block_trace(const chain::block_state_ptr &bsp)
TransactionTrace to_transaction_trace(const cache_trace &t)
ActionTrace to_action_trace(const chain::action_trace &at)
Used by to_transaction_trace for creation of action_trace_v0 or action_trace_v1.
vector< permission_level > authorization
Definition action.hpp:59
std::vector< char > return_value
Definition trace.hpp:47
std::optional< action_receipt > receipt
Definition trace.hpp:34
chain::packed_transaction_ptr trx
Definition trace.hpp:90
chain::transaction_trace_ptr trace
Definition trace.hpp:89