Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::impl::abi_to_variant Struct Reference

#include <abi_serializer.hpp>

Classes

struct  add_static_variant
 

Static Public Member Functions

template<typename M , typename Resolver , not_require_abi_t< M > = 1>
static void add (mutable_variant_object &mvo, const char *name, const M &v, Resolver, abi_traverse_context &ctx)
 
template<typename M , typename Resolver , require_abi_t< M > = 1>
static void add (mutable_variant_object &mvo, const char *name, const M &v, Resolver resolver, abi_traverse_context &ctx)
 
template<typename M , typename Resolver , require_abi_t< M > = 1>
static void add (mutable_variant_object &mvo, const char *name, const vector< M > &v, Resolver resolver, abi_traverse_context &ctx)
 
template<typename M , typename Resolver , require_abi_t< M > = 1>
static void add (mutable_variant_object &mvo, const char *name, const std::shared_ptr< M > &v, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver , typename... Args>
static void add (mutable_variant_object &mvo, const char *name, const std::variant< Args... > &v, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static bool add_special_logging (mutable_variant_object &mvo, const char *name, const action &act, Resolver &resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void add (mutable_variant_object &out, const char *name, const action &act, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void add (mutable_variant_object &out, const char *name, const action_trace &act_trace, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void add (mutable_variant_object &out, const char *name, const packed_transaction &ptrx, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void add (mutable_variant_object &out, const char *name, const transaction &trx, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void add (mutable_variant_object &out, const char *name, const signed_block &block, Resolver resolver, abi_traverse_context &ctx)
 

Detailed Description

Definition at line 331 of file abi_serializer.hpp.

Member Function Documentation

◆ add() [1/10]

template<typename M , typename Resolver , require_abi_t< M > = 1>
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & mvo,
const char * name,
const M & v,
Resolver resolver,
abi_traverse_context & ctx )
static

template which overloads add for types which contain ABI information in their trees for these types we create new ABI aware visitors

◆ add() [2/10]

template<typename M , typename Resolver , require_abi_t< M > >
void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & mvo,
const char * name,
const M & v,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

template which overloads add for types which are not relvant to ABI information and can be degraded to the normal ::to_variant(...) processing

Definition at line 337 of file abi_serializer.hpp.

338 {
339 auto h = ctx.enter_scope();
340 mvo(name,v);
341 }
std::string name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add() [3/10]

template<typename M , typename Resolver , require_abi_t< M > = 1>
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & mvo,
const char * name,
const std::shared_ptr< M > & v,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

template which overloads add for shared_ptr of types which contain ABI information in their trees for these members we call add in order to trigger further processing

Definition at line 374 of file abi_serializer.hpp.

375 {
376 auto h = ctx.enter_scope();
377 if( !v ) return;
378 mutable_variant_object obj_mvo;
379 add(obj_mvo, "_", *v, resolver, ctx);
380 mvo(name, std::move(obj_mvo["_"]));
381 }
static void add(mutable_variant_object &mvo, const char *name, const M &v, Resolver, abi_traverse_context &ctx)
Here is the call graph for this function:

◆ add() [4/10]

template<typename Resolver , typename... Args>
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & mvo,
const char * name,
const std::variant< Args... > & v,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

Definition at line 401 of file abi_serializer.hpp.

402 {
403 auto h = ctx.enter_scope();
404 mutable_variant_object obj_mvo;
405 add_static_variant<Resolver> adder(obj_mvo, resolver, ctx);
406 std::visit(adder, v);
407 mvo(name, std::move(obj_mvo["_"]));
408 }
Here is the call graph for this function:

◆ add() [5/10]

template<typename M , typename Resolver , require_abi_t< M > = 1>
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & mvo,
const char * name,
const vector< M > & v,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

template which overloads add for vectors of types which contain ABI information in their trees for these members we call add in order to trigger further processing

Definition at line 355 of file abi_serializer.hpp.

356 {
357 auto h = ctx.enter_scope();
358 vector<fc::variant> array;
359 array.reserve(v.size());
360
361 for (const auto& iter: v) {
362 mutable_variant_object elem_mvo;
363 add(elem_mvo, "_", iter, resolver, ctx);
364 array.emplace_back(std::move(elem_mvo["_"]));
365 }
366 mvo(name, std::move(array));
367 }
value::array array
Here is the call graph for this function:

◆ add() [6/10]

template<typename Resolver >
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & out,
const char * name,
const action & act,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

overload of to_variant_object for actions

This matches the FC_REFLECT for this type, but this is provided to extract the contents of act.data

Template Parameters
Resolver
Parameters
act
resolver
Returns

Definition at line 440 of file abi_serializer.hpp.

441 {
443 auto h = ctx.enter_scope();
444 mutable_variant_object mvo;
445 mvo("account", act.account);
446 mvo("name", act.name);
447 mvo("authorization", act.authorization);
448
449 if( add_special_logging(mvo, name, act, resolver, ctx) ) {
450 out(name, std::move(mvo));
451 return;
452 }
453
454 auto set_hex_data = [&](mutable_variant_object& mvo, const char* name, const bytes& data) {
455 if( !ctx.is_logging() ) {
456 mvo(name, data);
457 } else {
459 sub_obj( "size", data.size() );
460 if( data.size() > impl::hex_log_max_size ) {
461 sub_obj( "trimmed_hex", std::vector<char>(&data[0], &data[0] + impl::hex_log_max_size) );
462 } else {
463 sub_obj( "hex", data );
464 }
465 mvo(name, std::move(sub_obj));
466 }
467 };
468
469 try {
470 auto abi = resolver(act.account);
471 if (abi) {
472 auto type = abi->get_action_type(act.name);
473 if (!type.empty()) {
474 try {
475 binary_to_variant_context _ctx(*abi, ctx, type);
476 _ctx.short_path = true; // Just to be safe while avoiding the complexity of threading an override boolean all over the place
477 mvo( "data", abi->_binary_to_variant( type, act.data, _ctx ));
478 set_hex_data(mvo, "hex_data", act.data);
479 } catch(...) {
480 // any failure to serialize data, then leave as not serailzed
481 set_hex_data(mvo, "data", act.data);
482 }
483 } else {
484 set_hex_data(mvo, "data", act.data);
485 }
486 } else {
487 set_hex_data(mvo, "data", act.data);
488 }
489 } catch(...) {
490 set_hex_data(mvo, "data", act.data);
491 }
492 out(name, std::move(mvo));
493 }
An order-preserving dictionary of variants.
vector< char > bytes
Definition types.hpp:243
defines visit functions for T Unless this is specialized, visit() will not be defined for T.
Definition reflect.hpp:33
static bool add_special_logging(mutable_variant_object &mvo, const char *name, const action &act, Resolver &resolver, abi_traverse_context &ctx)
Here is the call graph for this function:

◆ add() [7/10]

template<typename Resolver >
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & out,
const char * name,
const action_trace & act_trace,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

overload of to_variant_object for action_trace

This matches the FC_REFLECT for this type, but this is provided to extract the contents of action_trace.return_value

Template Parameters
Resolver
Parameters
action_trace
resolver
Returns

Definition at line 505 of file abi_serializer.hpp.

506 {
508 auto h = ctx.enter_scope();
509 mutable_variant_object mvo;
510
511 mvo("action_ordinal", act_trace.action_ordinal);
512 mvo("creator_action_ordinal", act_trace.creator_action_ordinal);
513 mvo("closest_unnotified_ancestor_action_ordinal", act_trace.closest_unnotified_ancestor_action_ordinal);
514 mvo("receipt", act_trace.receipt);
515 mvo("receiver", act_trace.receiver);
516 add(mvo, "act", act_trace.act, resolver, ctx);
517 mvo("context_free", act_trace.context_free);
518 mvo("elapsed", act_trace.elapsed);
519 mvo("console", act_trace.console);
520 mvo("trx_id", act_trace.trx_id);
521 mvo("block_num", act_trace.block_num);
522 mvo("block_time", act_trace.block_time);
523 mvo("producer_block_id", act_trace.producer_block_id);
524 mvo("account_ram_deltas", act_trace.account_ram_deltas);
525 mvo("except", act_trace.except);
526 mvo("error_code", act_trace.error_code);
527
528 mvo("return_value_hex_data", act_trace.return_value);
529 auto act = act_trace.act;
530 try {
531 auto abi = resolver(act.account);
532 if (abi) {
533 auto type = abi->get_action_result_type(act.name);
534 if (!type.empty()) {
535 binary_to_variant_context _ctx(*abi, ctx, type);
536 _ctx.short_path = true; // Just to be safe while avoiding the complexity of threading an override boolean all over the place
537 mvo( "return_value_data", abi->_binary_to_variant( type, act_trace.return_value, _ctx ));
538 }
539 }
540 } catch(...) {}
541 out(name, std::move(mvo));
542 }
Here is the call graph for this function:

◆ add() [8/10]

template<typename Resolver >
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & out,
const char * name,
const packed_transaction & ptrx,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

overload of to_variant_object for packed_transaction

This matches the FC_REFLECT for this type, but this is provided to allow extracting the contents of ptrx.transaction

Template Parameters
Resolver
Parameters
act
resolver
Returns

Definition at line 554 of file abi_serializer.hpp.

555 {
557 auto h = ctx.enter_scope();
558 mutable_variant_object mvo;
559 auto trx = ptrx.get_transaction();
560 mvo("id", trx.id());
561 mvo("signatures", ptrx.get_signatures());
562 mvo("compression", ptrx.get_compression());
563 mvo("packed_context_free_data", ptrx.get_packed_context_free_data());
564 mvo("context_free_data", ptrx.get_context_free_data());
565 if( !ctx.is_logging() )
566 mvo("packed_trx", ptrx.get_packed_transaction());
567 add(mvo, "transaction", trx, resolver, ctx);
568
569 out(name, std::move(mvo));
570 }
Here is the call graph for this function:

◆ add() [9/10]

template<typename Resolver >
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & out,
const char * name,
const signed_block & block,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

overload of to_variant_object for signed_block

This matches the FC_REFLECT for this type, but this is provided to allow extracting the contents of block.header_extensions and block.block_extensions

Definition at line 609 of file abi_serializer.hpp.

610 {
612 auto h = ctx.enter_scope();
613 mutable_variant_object mvo;
614 mvo("timestamp", block.timestamp);
615 mvo("producer", block.producer);
616 mvo("confirmed", block.confirmed);
617 mvo("previous", block.previous);
618 mvo("transaction_mroot", block.transaction_mroot);
619 mvo("action_mroot", block.action_mroot);
620 mvo("schedule_version", block.schedule_version);
621 mvo("new_producers", block.new_producers);
622
623 // process contents of block.header_extensions
624 flat_multimap<uint16_t, block_header_extension> header_exts = block.validate_and_extract_header_extensions();
625 if ( header_exts.count(protocol_feature_activation::extension_id() > 0) ) {
626 const auto& new_protocol_features =
627 std::get<protocol_feature_activation>(header_exts.lower_bound(protocol_feature_activation::extension_id())->second).protocol_features;
628 vector<fc::variant> pf_array;
629 pf_array.reserve(new_protocol_features.size());
630 for (auto feature : new_protocol_features) {
631 mutable_variant_object feature_mvo;
632 add(feature_mvo, "feature_digest", feature, resolver, ctx);
633 pf_array.push_back(feature_mvo);
634 }
635 mvo("new_protocol_features", pf_array);
636 }
637 if ( header_exts.count(producer_schedule_change_extension::extension_id())) {
638 const auto& new_producer_schedule =
639 std::get<producer_schedule_change_extension>(header_exts.lower_bound(producer_schedule_change_extension::extension_id())->second);
640 mvo("new_producer_schedule", new_producer_schedule);
641 }
642
643 mvo("producer_signature", block.producer_signature);
644 add(mvo, "transactions", block.transactions, resolver, ctx);
645
646 // process contents of block.block_extensions
647 auto block_exts = block.validate_and_extract_extensions();
648 if ( block_exts.count(additional_block_signatures_extension::extension_id()) > 0) {
649 const auto& additional_signatures =
650 std::get<additional_block_signatures_extension>(block_exts.lower_bound(additional_block_signatures_extension::extension_id())->second);
651 mvo("additional_signatures", additional_signatures);
652 }
653
654 out(name, std::move(mvo));
655 }
Here is the call graph for this function:

◆ add() [10/10]

template<typename Resolver >
static void sysio::chain::impl::abi_to_variant::add ( mutable_variant_object & out,
const char * name,
const transaction & trx,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

overload of to_variant_object for transaction

This matches the FC_REFLECT for this type, but this is provided to allow extracting the contents of trx.transaction_extensions

Definition at line 578 of file abi_serializer.hpp.

579 {
581 auto h = ctx.enter_scope();
582 mutable_variant_object mvo;
583 mvo("expiration", trx.expiration);
584 mvo("ref_block_num", trx.ref_block_num);
585 mvo("ref_block_prefix", trx.ref_block_prefix);
586 mvo("max_net_usage_words", trx.max_net_usage_words);
587 mvo("max_cpu_usage_ms", trx.max_cpu_usage_ms);
588 mvo("delay_sec", trx.delay_sec);
589 add(mvo, "context_free_actions", trx.context_free_actions, resolver, ctx);
590 add(mvo, "actions", trx.actions, resolver, ctx);
591
592 // process contents of block.transaction_extensions
593 auto exts = trx.validate_and_extract_extensions();
595 const auto& deferred_transaction_generation = std::get<deferred_transaction_generation_context>(exts.lower_bound(deferred_transaction_generation_context::extension_id())->second);
596 mvo("deferred_transaction_generation", deferred_transaction_generation);
597 }
598
599 out(name, std::move(mvo));
600 }
Here is the call graph for this function:

◆ add_special_logging()

template<typename Resolver >
static bool sysio::chain::impl::abi_to_variant::add_special_logging ( mutable_variant_object & mvo,
const char * name,
const action & act,
Resolver & resolver,
abi_traverse_context & ctx )
inlinestatic

Definition at line 411 of file abi_serializer.hpp.

411 {
412 if( !ctx.is_logging() ) return false;
413
414 try {
415
416 if( act.account == config::system_account_name && act.name == "setcode"_n ) {
417 auto setcode_act = act.data_as<setcode>();
418 if( setcode_act.code.size() > 0 ) {
419 fc::sha256 code_hash = fc::sha256::hash(setcode_act.code.data(), (uint32_t) setcode_act.code.size());
420 mvo("code_hash", code_hash);
421 }
422 return false; // still want the hex data included
423 }
424
425 } catch(...) {} // return false
426
427 return false;
428 }
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
unsigned int uint32_t
Definition stdint.h:126
Here is the call graph for this function:
Here is the caller graph for this function:

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