16#include <boost/container/flat_set.hpp>
17#include <boost/multiprecision/cpp_int.hpp>
25namespace fc {
class variant; }
28 using chain::controller;
29 using std::unique_ptr;
35 using chain::transaction;
37 using boost::container::flat_set;
40 using chain::authority;
44 using chain::abi_serializer;
65template<
typename Type>
69 }
FC_RETHROW_EXCEPTIONS(warn,
"Could not convert ${desc} string '${str}' to key type.", (
"desc", desc)(
"str",str) )
78template<
typename Type>
90 const std::optional<account_query_db>& aqdb;
92 bool shorten_abi_errors =
true;
223 std::optional<abi_def>
abi;
242 std::optional<abi_def>
abi;
268 std::optional<chain::blob>
abi;
458 template<
typename Function>
461 const auto&
d = db.
db();
462 const auto* t_id =
d.find<
chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple(code, scope, table));
463 if (t_id !=
nullptr) {
465 decltype(t_id->id) next_tid(t_id->id._id + 1);
466 auto lower = idx.lower_bound(boost::make_tuple(t_id->id));
467 auto upper = idx.lower_bound(boost::make_tuple(next_tid));
469 for (
auto itr = lower; itr != upper; ++itr) {
479 template <
typename IndexType,
typename SecKeyType,
typename ConvFn>
482 const auto&
d = db.
db();
488 bool primary =
false;
490 const auto* t_id =
d.find<
chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple(
p.code, scope,
p.table));
491 const auto* index_t_id =
d.find<
chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple(
p.code, scope,
name(table_with_index)));
492 if( t_id !=
nullptr && index_t_id !=
nullptr ) {
493 using secondary_key_type = std::result_of_t<
decltype(conv)(SecKeyType)>;
494 static_assert( std::is_same<typename IndexType::value_type::secondary_key_type, secondary_key_type>::value,
"Return type of conv does not match type of secondary key for IndexType" );
496 const auto& secidx =
d.get_index<IndexType, chain::by_secondary>();
497 auto lower_bound_lookup_tuple = std::make_tuple( index_t_id->id._id,
499 std::numeric_limits<uint64_t>::lowest() );
500 auto upper_bound_lookup_tuple = std::make_tuple( index_t_id->id._id,
502 std::numeric_limits<uint64_t>::max() );
504 if(
p.lower_bound.
size() ) {
505 if(
p.key_type ==
"name" ) {
508 std::get<1>(lower_bound_lookup_tuple) = conv( lv );
511 std::get<1>(lower_bound_lookup_tuple) = conv( lv );
515 if(
p.upper_bound.
size() ) {
516 if(
p.key_type ==
"name" ) {
519 std::get<1>(upper_bound_lookup_tuple) = conv( uv );
522 std::get<1>(upper_bound_lookup_tuple) = conv( uv );
526 if( upper_bound_lookup_tuple < lower_bound_lookup_tuple )
529 auto walk_table_row_range = [&](
auto itr,
auto end_itr ) {
534 const auto* itr2 =
d.find<
chain::key_value_object, chain::by_scope_primary>( boost::make_tuple(t_id->id, itr->primary_key) );
535 if( itr2 ==
nullptr )
continue;
545 if(
p.show_payer && *
p.show_payer ) {
548 result.rows.emplace_back( std::move(data_var) );
553 if( itr != end_itr ) {
555 result.next_key =
convert_to_string(itr->secondary_key,
p.key_type,
p.encode_type,
"next_key - next lower bound");
559 auto lower = secidx.lower_bound( lower_bound_lookup_tuple );
560 auto upper = secidx.upper_bound( upper_bound_lookup_tuple );
561 if(
p.reverse && *
p.reverse ) {
562 walk_table_row_range( boost::make_reverse_iterator(upper), boost::make_reverse_iterator(lower) );
564 walk_table_row_range( lower, upper );
570 template <
typename IndexType>
573 const auto&
d = db.
db();
580 if( t_id !=
nullptr ) {
581 const auto& idx =
d.get_index<IndexType, chain::by_scope_primary>();
582 auto lower_bound_lookup_tuple = std::make_tuple( t_id->id, std::numeric_limits<uint64_t>::lowest() );
583 auto upper_bound_lookup_tuple = std::make_tuple( t_id->id, std::numeric_limits<uint64_t>::max() );
585 if(
p.lower_bound.
size() ) {
586 if(
p.key_type ==
"name" ) {
588 std::get<1>(lower_bound_lookup_tuple) =
s.to_uint64_t();
591 std::get<1>(lower_bound_lookup_tuple) = lv;
595 if(
p.upper_bound.
size() ) {
596 if(
p.key_type ==
"name" ) {
598 std::get<1>(upper_bound_lookup_tuple) =
s.to_uint64_t();
601 std::get<1>(upper_bound_lookup_tuple) = uv;
605 if( upper_bound_lookup_tuple < lower_bound_lookup_tuple )
608 auto walk_table_row_range = [&](
auto itr,
auto end_itr ) {
622 if(
p.show_payer && *
p.show_payer ) {
625 result.rows.emplace_back( std::move(data_var) );
628 if( itr != end_itr ) {
630 result.next_key =
convert_to_string(itr->primary_key,
p.key_type,
p.encode_type,
"next_key - next lower bound");
634 auto lower = idx.lower_bound( lower_bound_lookup_tuple );
635 auto upper = idx.upper_bound( upper_bound_lookup_tuple );
636 if(
p.reverse && *
p.reverse ) {
637 walk_table_row_range( boost::make_reverse_iterator(upper), boost::make_reverse_iterator(lower) );
639 walk_table_row_range( lower, upper );
655 std::optional<trx_retry_db>& trx_retry;
657 const bool api_accept_transactions;
693 constexpr const char i64[] =
"i64";
694 constexpr const char i128[] =
"i128";
695 constexpr const char i256[] =
"i256";
698 constexpr const char sha256[] =
"sha256";
700 constexpr const char dec[] =
"dec";
701 constexpr const char hex[] =
"hex";
704 template<const
char*key_type , const
char *encoding=chain_apis::dec>
717 memcpy(buffer, v.data(), 32);
735 memcpy(buffer, v.data(), 20);
753 boost::multiprecision::export_bits(v, buffer, 8,
false);
754 memcpy(&k[0], buffer + 16, 16);
755 memcpy(&k[1], buffer, 16);
821 (server_version)(chain_id)(head_block_num)(last_irreversible_block_num)(last_irreversible_block_id)
822 (head_block_id)(head_block_time)(head_block_producer)
823 (virtual_block_cpu_limit)(virtual_block_net_limit)(block_cpu_limit)(block_net_limit)
824 (server_version_string)(fork_db_head_block_num)(fork_db_head_block_id)(server_full_version_string)
825 (total_cpu_weight)(total_net_weight)(earliest_available_block_num)(last_irreversible_block_time))
826FC_REFLECT(
sysio::chain_apis::read_only::get_transaction_status_params, (
id) )
827FC_REFLECT(
sysio::chain_apis::read_only::get_transaction_status_results, (
state)(block_number)(block_id)(block_timestamp)(expiration)(head_number)(head_id)
828 (head_timestamp)(irreversible_number)(irreversible_id)(irreversible_timestamp)(earliest_tracked_block_id)(earliest_tracked_block_number) )
829FC_REFLECT(
sysio::chain_apis::read_only::get_activated_protocol_features_params, (lower_bound)(upper_bound)(limit)(search_by_block_num)(reverse) )
830FC_REFLECT(
sysio::chain_apis::read_only::get_activated_protocol_features_results, (activated_protocol_features)(more) )
831FC_REFLECT(
sysio::chain_apis::read_only::get_block_params, (block_num_or_id))
832FC_REFLECT(
sysio::chain_apis::read_only::get_block_info_params, (block_num))
833FC_REFLECT(
sysio::chain_apis::read_only::get_block_header_state_params, (block_num_or_id))
835FC_REFLECT(
sysio::chain_apis::read_write::push_transaction_results, (transaction_id)(processed) )
836FC_REFLECT(
sysio::chain_apis::read_write::send_transaction2_params, (return_failure_trace)(retry_trx)(retry_trx_num_blocks)(transaction) )
838FC_REFLECT(
sysio::chain_apis::read_only::get_table_rows_params, (json)(code)(scope)(table)(table_key)(lower_bound)(upper_bound)(limit)(
key_type)(index_position)(encode_type)(reverse)(show_payer) )
839FC_REFLECT(
sysio::chain_apis::read_only::get_table_rows_result, (rows)(more)(next_key) );
841FC_REFLECT(
sysio::chain_apis::read_only::get_table_by_scope_params, (code)(table)(lower_bound)(upper_bound)(limit)(reverse) )
842FC_REFLECT(
sysio::chain_apis::read_only::get_table_by_scope_result_row, (code)(scope)(table)(payer)(
count));
845FC_REFLECT(
sysio::chain_apis::read_only::get_currency_balance_params, (code)(account)(symbol));
847FC_REFLECT(
sysio::chain_apis::read_only::get_currency_stats_result, (supply)(max_supply)(issuer));
849FC_REFLECT(
sysio::chain_apis::read_only::get_producers_params, (json)(lower_bound)(limit) )
850FC_REFLECT(
sysio::chain_apis::read_only::get_producers_result, (rows)(total_producer_vote_weight)(more) );
853FC_REFLECT(
sysio::chain_apis::read_only::get_producer_schedule_result, (active)(pending)(proposed) );
855FC_REFLECT(
sysio::chain_apis::read_only::get_scheduled_transactions_params, (json)(lower_bound)(limit) )
856FC_REFLECT(
sysio::chain_apis::read_only::get_scheduled_transactions_result, (transactions)(more) );
859 (account_name)(head_block_num)(head_block_time)(privileged)(last_code_update)(created)
860 (core_liquid_balance)(ram_quota)(net_weight)(cpu_weight)(net_limit)(cpu_limit)(ram_usage)(permissions)
861 (total_resources)(self_delegated_bandwidth)(refund_request)(voter_info)(rex_info)
862 (subjective_cpu_bill_limit) (sysio_any_linked_actions) )
864FC_REFLECT(
sysio::chain_apis::read_only::get_code_results, (account_name)(code_hash)(wast)(wasm)(abi) )
865FC_REFLECT(
sysio::chain_apis::read_only::get_code_hash_results, (account_name)(code_hash) )
866FC_REFLECT(
sysio::chain_apis::read_only::get_abi_results, (account_name)(abi) )
867FC_REFLECT(
sysio::chain_apis::read_only::get_account_params, (account_name)(expected_core_symbol) )
868FC_REFLECT(
sysio::chain_apis::read_only::get_code_params, (account_name)(code_as_wasm) )
869FC_REFLECT(
sysio::chain_apis::read_only::get_code_hash_params, (account_name) )
870FC_REFLECT(
sysio::chain_apis::read_only::get_abi_params, (account_name) )
871FC_REFLECT(
sysio::chain_apis::read_only::get_raw_code_and_abi_params, (account_name) )
872FC_REFLECT(
sysio::chain_apis::read_only::get_raw_code_and_abi_results, (account_name)(wasm)(abi) )
873FC_REFLECT(
sysio::chain_apis::read_only::get_raw_abi_params, (account_name)(abi_hash) )
874FC_REFLECT(
sysio::chain_apis::read_only::get_raw_abi_results, (account_name)(code_hash)(abi_hash)(abi) )
877FC_REFLECT(
sysio::chain_apis::read_only::abi_json_to_bin_result, (binargs) )
879FC_REFLECT(
sysio::chain_apis::read_only::abi_bin_to_json_result, (args) )
880FC_REFLECT(
sysio::chain_apis::read_only::get_required_keys_params, (transaction)(available_keys) )
881FC_REFLECT(
sysio::chain_apis::read_only::get_required_keys_result, (required_keys) )
882FC_REFLECT(
sysio::chain_apis::read_only::compute_transaction_params, (transaction))
883FC_REFLECT(
sysio::chain_apis::read_only::compute_transaction_results, (transaction_id)(processed) )
const char * data() const
An order-preserving dictionary of variants.
An order-preserving dictionary of variants.
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
const chainbase::database & db() const
The table_id_object class tracks the mapping of (scope, code, table) to an opaque identifier.
void walk_key_value_table(const name &code, const name &scope, const name &table, Function f) const
static void copy_inline_row(const chain::key_value_object &obj, vector< char > &data)
static const string KEYi64
read_only::get_table_rows_result get_table_rows_by_seckey(const read_only::get_table_rows_params &p, const abi_def &abi, ConvFn conv) const
abi_bin_to_json_result abi_bin_to_json(const abi_bin_to_json_params ¶ms) const
abi_json_to_bin_result abi_json_to_bin(const abi_json_to_bin_params ¶ms) const
chain::symbol extract_core_symbol() const
get_raw_code_and_abi_results get_raw_code_and_abi(const get_raw_code_and_abi_params ¶ms) const
fc::variant get_block_info(const get_block_info_params ¶ms) const
fc::variant get_block(const get_block_params ¶ms) const
get_accounts_by_authorizers_result get_accounts_by_authorizers(const get_accounts_by_authorizers_params &args) const
vector< asset > get_currency_balance(const get_currency_balance_params ¶ms) const
get_raw_abi_results get_raw_abi(const get_raw_abi_params ¶ms) const
get_abi_results get_abi(const get_abi_params ¶ms) const
fc::variant get_currency_stats(const get_currency_stats_params ¶ms) const
void compute_transaction(const compute_transaction_params ¶ms, chain::plugin_interface::next_function< compute_transaction_results > next) const
get_account_results get_account(const get_account_params ¶ms) const
get_producers_result get_producers(const get_producers_params ¶ms) const
read_only(const controller &db, const std::optional< account_query_db > &aqdb, const fc::microseconds &abi_serializer_max_time, const producer_plugin *producer_plug, const trx_finality_status_processing *trx_finality_status_proc)
get_table_rows_result get_table_rows(const get_table_rows_params ¶ms) const
get_transaction_status_results get_transaction_status(const get_transaction_status_params ¶ms) const
get_code_results get_code(const get_code_params ¶ms) const
get_activated_protocol_features_results get_activated_protocol_features(const get_activated_protocol_features_params ¶ms) const
get_scheduled_transactions_result get_scheduled_transactions(const get_scheduled_transactions_params ¶ms) const
read_only::get_table_rows_result get_table_rows_ex(const read_only::get_table_rows_params &p, const abi_def &abi) const
get_required_keys_result get_required_keys(const get_required_keys_params ¶ms) const
void set_shorten_abi_errors(bool f)
get_transaction_id_result get_transaction_id(const get_transaction_id_params ¶ms) const
fc::variant get_block_header_state(const get_block_header_state_params ¶ms) const
get_table_by_scope_result get_table_by_scope(const get_table_by_scope_params ¶ms) const
get_producer_schedule_result get_producer_schedule(const get_producer_schedule_params ¶ms) const
static uint64_t get_table_index_name(const read_only::get_table_rows_params &p, bool &primary)
void push_block(push_block_params &¶ms, chain::plugin_interface::next_function< push_block_results > next)
void push_transactions(const push_transactions_params ¶ms, chain::plugin_interface::next_function< push_transactions_results > next)
void send_transaction(const send_transaction_params ¶ms, chain::plugin_interface::next_function< send_transaction_results > next)
fc::variant_object push_transaction_params
void send_transaction2(const send_transaction2_params ¶ms, chain::plugin_interface::next_function< send_transaction_results > next)
void push_transaction(const push_transaction_params ¶ms, chain::plugin_interface::next_function< push_transaction_results > next)
void plugin_initialize(const variables_map &options)
static void handle_db_exhaustion()
bool accept_block(const chain::signed_block_ptr &block, const chain::block_id_type &id, const chain::block_state_ptr &bsp)
bool api_accept_transactions() const
fc::microseconds get_abi_serializer_max_time() const
chain_apis::read_write get_read_write_api()
void enable_accept_transactions()
bool account_queries_enabled() const
void do_hard_replay(const variables_map &options)
chain_apis::read_only get_read_only_api() const
static void handle_guard_exception(const chain::guard_exception &e)
bool transaction_finality_status_enabled() const
chain::chain_id_type get_chain_id() const
static void handle_bad_alloc()
virtual void set_program_options(options_description &cli, options_description &cfg) override
void accept_transaction(const chain::packed_transaction_ptr &trx, chain::plugin_interface::next_function< chain::transaction_trace_ptr > next)
fc::variant get_log_trx_trace(const chain::transaction_trace_ptr &trx_trace) const
bool accept_transactions() const
fc::variant get_log_trx(const transaction &trx) const
void handle_sighup() override
const auto & get_array() const
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
std::vector< fc::variant > variants
std::function< void(const std::variant< fc::exception_ptr, T > &)> next_function
string convert_to_string(const Type &source, const string &key_type, const string &encode_type, const string &desc)
constexpr const char hex[]
constexpr const char i256[]
constexpr const char float64[]
constexpr const char i64[]
uint64_t convert_to_type(const string &str, const string &desc)
constexpr const char dec[]
constexpr const char i128[]
constexpr const char float128[]
fc::crypto::public_key public_key_type
std::array< uint128_t, 2 > key256_t
std::shared_ptr< transaction_trace > transaction_trace_ptr
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found Unlinkable block Block does not guarantee concurrent execution without conflicts Block exhausted allowed resources Block is from the future Block is not signed by expected producer Block includes an ill formed protocol feature activation extension Block includes an ill formed additional block signature extension Error decompressing transaction Transaction should have at least one required authority Expired Transaction Invalid Reference Block Duplicate deferred transaction The transaction can not be found Transaction is too big Invalid transaction extension Transaction includes disallowed Transaction exceeded transient resource limit Account name already exists sysio_assert_message assertion failure Action can not be found Attempt to use unaccessible API Inline Action exceeds maximum size limit sysio_assert_code assertion failure uses restricted error code value action return value size too big Permission Query Exception Contract Table Query Exception Database is an unknown or unsupported version guard_exception
std::shared_ptr< const packed_transaction > packed_transaction_ptr
sysio::chain::action_name action_name
unsigned __int128 uint128_t
fc::ripemd160 checksum160_type
secondary_index< key256_t, index256_object_type >::index_index index256_index
fc::sha256 checksum256_type
std::shared_ptr< signed_block > signed_block_ptr
checksum_type transaction_id_type
chainbase::shared_multi_index_container< key_value_object, indexed_by< ordered_unique< tag< by_id >, member< key_value_object, key_value_object::id_type, &key_value_object::id > >, ordered_unique< tag< by_scope_primary >, composite_key< key_value_object, member< key_value_object, table_id, &key_value_object::t_id >, member< key_value_object, uint64_t, &key_value_object::primary_key > >, composite_key_compare< std::less< table_id >, std::less< uint64_t > > > > > key_value_index
std::shared_ptr< block_state > block_state_ptr
#define APPBASE_PLUGIN_REQUIRES(PLUGINS)
const CharType(& source)[N]
const fc::microseconds abi_serializer_max_time
sysio::chain_apis::read_only::get_info_results get_info()
producer_name(block_signing_key)) FC_REFLECT(producer_set_def
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
#define FC_REFLECT_EMPTY(TYPE)
unsigned __int64 uint64_t
static yield_function_t create_yield_function(const fc::microseconds &max_serialization_time)
void set_abi(const abi_def &abi, const yield_function_t &yield)
type_name get_table_type(name action) const
fc::variant binary_to_variant(const std::string_view &type, const bytes &binary, const yield_function_t &yield, bool short_path=false) const
Immutable except for fc::from_variant.
chain::index256_index index_type
boost::multiprecision::uint256_t input_type
chain::index256_index index_type
chain::index256_index index_type
std::optional< name > action
std::optional< std::vector< linked_action > > linked_actions
chain::transaction_id_type transaction_id
std::optional< abi_def > abi
std::optional< symbol > expected_core_symbol
fc::time_point last_code_update
fc::variant self_delegated_bandwidth
vector< permission > permissions
fc::variant total_resources
account_resource_limit net_limit
std::optional< account_resource_limit > subjective_cpu_bill_limit
account_resource_limit cpu_limit
fc::time_point head_block_time
std::optional< asset > core_liquid_balance
std::vector< linked_action > sysio_any_linked_actions
fc::variant refund_request
std::optional< uint32_t > upper_bound
std::optional< uint32_t > lower_bound
fc::variants activated_protocol_features
std::optional< uint32_t > more
std::optional< abi_def > abi
std::optional< string > symbol
std::optional< uint32_t > earliest_available_block_num
uint32_t last_irreversible_block_num
account_name head_block_producer
uint64_t virtual_block_net_limit
std::optional< string > server_full_version_string
std::optional< chain::block_id_type > fork_db_head_block_id
fc::time_point head_block_time
std::optional< uint64_t > total_net_weight
std::optional< fc::time_point > last_irreversible_block_time
std::optional< uint64_t > total_cpu_weight
chain::block_id_type head_block_id
std::optional< string > server_version_string
uint64_t virtual_block_cpu_limit
chain::chain_id_type chain_id
chain::block_id_type last_irreversible_block_id
std::optional< uint32_t > fork_db_head_block_num
vector< fc::variant > rows
one row per item, either encoded as hex string or JSON object
double total_producer_vote_weight
string more
fill lower_bound with this value to fetch more rows
std::optional< fc::sha256 > abi_hash
std::optional< chain::blob > abi
flat_set< public_key_type > available_keys
flat_set< public_key_type > required_keys
string more
fill lower_bound with this to fetch next set of transactions
fc::variants transactions
std::optional< bool > reverse
vector< get_table_by_scope_result_row > rows
string more
fill lower_bound with this value to fetch more rows
std::optional< bool > reverse
std::optional< bool > show_payer
vector< fc::variant > rows
one row per item, either encoded as hex String or JSON object
string next_key
fill lower_bound with this value to fetch more rows
chain::transaction_id_type id
std::optional< uint32_t > block_number
std::optional< fc::time_point > expiration
chain::block_id_type earliest_tracked_block_id
chain::block_id_type head_id
chain::block_id_type irreversible_id
fc::time_point irreversible_timestamp
std::optional< fc::time_point > block_timestamp
uint32_t irreversible_number
fc::time_point head_timestamp
uint32_t earliest_tracked_block_number
std::optional< chain::block_id_type > block_id
chain::transaction_id_type transaction_id
bool return_failure_trace
bool retry_trx
request transaction retry on validated transaction
std::optional< uint16_t > retry_trx_num_blocks
if retry_trx, report trace at specified blocks from executed or lib if not specified
memcpy((char *) pInfo->slotDescription, s, l)