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

Classes

class  account_query_db
 
struct  account_query_db_impl
 
struct  empty
 
struct  keytype_converter
 
struct  keytype_converter< chain_apis::i256 >
 
struct  keytype_converter< chain_apis::ripemd160, chain_apis::hex >
 
struct  keytype_converter< chain_apis::sha256, chain_apis::hex >
 
struct  linked_action
 
struct  permission
 
class  read_only
 
class  read_write
 
struct  resolver_factory
 
class  trx_finality_status_processing
 
struct  trx_finality_status_processing_impl
 
class  trx_retry_db
 
struct  trx_retry_db_impl
 

Typedefs

using trx_finality_status_processing_impl_ptr = std::unique_ptr<trx_finality_status_processing_impl>
 
using trx_finality_status_processing_ptr = std::unique_ptr<trx_finality_status_processing>
 
template<typename T >
using next_function = std::function<void(const std::variant<fc::exception_ptr, T>&)>
 

Functions

template<typename I >
std::string itoh (I n, size_t hlen=sizeof(I)<< 1)
 
template<>
uint64_t convert_to_type (const string &str, const string &desc)
 
template<>
double convert_to_type (const string &str, const string &desc)
 
template<typename Type >
string convert_to_string (const Type &source, const string &key_type, const string &encode_type, const string &desc)
 
template<>
string convert_to_string (const chain::key256_t &source, const string &key_type, const string &encode_type, const string &desc)
 
template<>
string convert_to_string (const float128_t &source, const string &key_type, const string &encode_type, const string &desc)
 
abi_def get_abi (const controller &db, const name &account)
 
string get_table_type (const abi_def &abi, const name &table_name)
 
fc::variant get_global_row (const database &db, const abi_def &abi, const abi_serializer &abis, const fc::microseconds &abi_serializer_max_time_us, bool shorten_abi_errors)
 
auto make_resolver (const controller &control, abi_serializer::yield_function_t yield)
 
template<typename Type >
Type convert_to_type (const string &str, const string &desc)
 
template<>
uint64_t convert_to_type (const string &str, const string &desc)
 
template<>
double convert_to_type (const string &str, const string &desc)
 
template<>
string convert_to_string (const chain::key256_t &source, const string &key_type, const string &encode_type, const string &desc)
 
template<>
string convert_to_string (const float128_t &source, const string &key_type, const string &encode_type, const string &desc)
 

Variables

constexpr const char i64 [] = "i64"
 
constexpr const char i128 [] = "i128"
 
constexpr const char i256 [] = "i256"
 
constexpr const char float64 [] = "float64"
 
constexpr const char float128 [] = "float128"
 
constexpr const char sha256 [] = "sha256"
 
constexpr const char ripemd160 [] = "ripemd160"
 
constexpr const char dec [] = "dec"
 
constexpr const char hex [] = "hex"
 

Typedef Documentation

◆ next_function

template<typename T >
using sysio::chain_apis::next_function = std::function<void(const std::variant<fc::exception_ptr, T>&)>

Definition at line 9 of file trx_retry_db.hpp.

◆ trx_finality_status_processing_impl_ptr

◆ trx_finality_status_processing_ptr

Function Documentation

◆ convert_to_string() [1/5]

template<>
string sysio::chain_apis::convert_to_string ( const chain::key256_t & source,
const string & key_type,
const string & encode_type,
const string & desc )

Definition at line 1635 of file chain_plugin.cpp.

1635 {
1636 try {
1637 if (key_type == chain_apis::sha256 || (key_type == chain_apis::i256 && encode_type == chain_apis::hex)) {
1638 auto byte_array = fixed_bytes<32>(source).extract_as_byte_array();
1639 fc::sha256 val(reinterpret_cast<char *>(byte_array.data()), byte_array.size());
1640 return std::string(val);
1641 } else if (key_type == chain_apis::i256) {
1642 auto byte_array = fixed_bytes<32>(source).extract_as_byte_array();
1643 fc::sha256 val(reinterpret_cast<char *>(byte_array.data()), byte_array.size());
1644 return std::string("0x") + std::string(val);
1645 } else if (key_type == chain_apis::ripemd160) {
1646 auto byte_array = fixed_bytes<20>(source).extract_as_byte_array();
1647 fc::ripemd160 val;
1648 memcpy(val._hash, byte_array.data(), byte_array.size() );
1649 return std::string(val);
1650 }
1651 SYS_ASSERT( false, chain_type_exception, "Incompatible key_type and encode_type for key256_t next_key" );
1652
1653 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} source '${source}' to string.", ("desc", desc)("source",source) )
1654}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
uint32_t _hash[5]
Definition ripemd160.hpp:71
std::array< uint8_t, Size > extract_as_byte_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...
const CharType(& source)[N]
Definition pointer.h:1204
memcpy((char *) pInfo->slotDescription, s, l)
struct @108 key_type
Here is the call graph for this function:

◆ convert_to_string() [2/5]

template<>
string sysio::chain_apis::convert_to_string ( const chain::key256_t & source,
const string & key_type,
const string & encode_type,
const string & desc )

Definition at line 1635 of file chain_plugin.cpp.

1635 {
1636 try {
1637 if (key_type == chain_apis::sha256 || (key_type == chain_apis::i256 && encode_type == chain_apis::hex)) {
1638 auto byte_array = fixed_bytes<32>(source).extract_as_byte_array();
1639 fc::sha256 val(reinterpret_cast<char *>(byte_array.data()), byte_array.size());
1640 return std::string(val);
1641 } else if (key_type == chain_apis::i256) {
1642 auto byte_array = fixed_bytes<32>(source).extract_as_byte_array();
1643 fc::sha256 val(reinterpret_cast<char *>(byte_array.data()), byte_array.size());
1644 return std::string("0x") + std::string(val);
1645 } else if (key_type == chain_apis::ripemd160) {
1646 auto byte_array = fixed_bytes<20>(source).extract_as_byte_array();
1647 fc::ripemd160 val;
1648 memcpy(val._hash, byte_array.data(), byte_array.size() );
1649 return std::string(val);
1650 }
1651 SYS_ASSERT( false, chain_type_exception, "Incompatible key_type and encode_type for key256_t next_key" );
1652
1653 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} source '${source}' to string.", ("desc", desc)("source",source) )
1654}
Here is the call graph for this function:

◆ convert_to_string() [3/5]

template<>
string sysio::chain_apis::convert_to_string ( const float128_t & source,
const string & key_type,
const string & encode_type,
const string & desc )

Definition at line 1657 of file chain_plugin.cpp.

1657 {
1658 try {
1660 return fc::variant(f).as<string>();
1661 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} from '${source}' to string.", ("desc", desc)("source",source) )
1662}
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
T as() const
Definition variant.hpp:327
float64_t f128_to_f64(float128_t a)
Definition f128_to_f64.c:44
Here is the call graph for this function:

◆ convert_to_string() [4/5]

template<>
string sysio::chain_apis::convert_to_string ( const float128_t & source,
const string & key_type,
const string & encode_type,
const string & desc )

Definition at line 1657 of file chain_plugin.cpp.

1657 {
1658 try {
1660 return fc::variant(f).as<string>();
1661 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} from '${source}' to string.", ("desc", desc)("source",source) )
1662}
Here is the call graph for this function:

◆ convert_to_string() [5/5]

template<typename Type >
string sysio::chain_apis::convert_to_string ( const Type & source,
const string & key_type,
const string & encode_type,
const string & desc )

Definition at line 1628 of file chain_plugin.cpp.

1628 {
1629 try {
1630 return fc::variant(source).as<string>();
1631 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} from '${source}' to string.", ("desc", desc)("source",source) )
1632}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_to_type() [1/5]

template<>
uint64_t sysio::chain_apis::convert_to_type ( const string & str,
const string & desc )

Definition at line 1585 of file chain_plugin.cpp.

1585 {
1586
1587 try {
1588 return boost::lexical_cast<uint64_t>(str.c_str(), str.size());
1589 } catch( ... ) { }
1590
1591 try {
1592 auto trimmed_str = str;
1593 boost::trim(trimmed_str);
1594 name s(trimmed_str);
1595 return s.to_uint64_t();
1596 } catch( ... ) { }
1597
1598 if (str.find(',') != string::npos) { // fix #6274 only match formats like 4,SYS
1599 try {
1600 auto symb = sysio::chain::symbol::from_string(str);
1601 return symb.value();
1602 } catch( ... ) { }
1603 }
1604
1605 try {
1606 return ( sysio::chain::string_to_symbol( 0, str.c_str() ) >> 8 );
1607 } catch( ... ) {
1608 SYS_ASSERT( false, chain_type_exception, "Could not convert ${desc} string '${str}' to any of the following: "
1609 "uint64_t, valid name, or valid symbol (with or without the precision)",
1610 ("desc", desc)("str", str));
1611 }
1612}
std::string name
static symbol from_string(const string &from)
Definition symbol.hpp:68
return str
Definition CLI11.hpp:1359
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_to_type() [2/5]

template<>
double sysio::chain_apis::convert_to_type ( const string & str,
const string & desc )

Definition at line 1615 of file chain_plugin.cpp.

1615 {
1616 double val{};
1617 try {
1618 val = fc::variant(str).as<double>();
1619 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} string '${str}' to key type.", ("desc", desc)("str",str) )
1620
1621 SYS_ASSERT( !std::isnan(val), chain::contract_table_query_exception,
1622 "Converted ${desc} string '${str}' to NaN which is not a permitted value for the key type", ("desc", desc)("str",str) );
1623
1624 return val;
1625}
Here is the call graph for this function:

◆ convert_to_type() [3/5]

template<typename Type >
Type sysio::chain_apis::convert_to_type ( const string & str,
const string & desc )

Definition at line 66 of file chain_plugin.hpp.

66 {
67 try {
68 return fc::variant(str).as<Type>();
69 } FC_RETHROW_EXCEPTIONS(warn, "Could not convert ${desc} string '${str}' to key type.", ("desc", desc)("str",str) )
70}
Type
Type of JSON value.
Definition rapidjson.h:644
Here is the call graph for this function:

◆ convert_to_type() [4/5]

template<>
uint64_t sysio::chain_apis::convert_to_type ( const string & str,
const string & desc )

Definition at line 1585 of file chain_plugin.cpp.

1585 {
1586
1587 try {
1588 return boost::lexical_cast<uint64_t>(str.c_str(), str.size());
1589 } catch( ... ) { }
1590
1591 try {
1592 auto trimmed_str = str;
1593 boost::trim(trimmed_str);
1594 name s(trimmed_str);
1595 return s.to_uint64_t();
1596 } catch( ... ) { }
1597
1598 if (str.find(',') != string::npos) { // fix #6274 only match formats like 4,SYS
1599 try {
1600 auto symb = sysio::chain::symbol::from_string(str);
1601 return symb.value();
1602 } catch( ... ) { }
1603 }
1604
1605 try {
1606 return ( sysio::chain::string_to_symbol( 0, str.c_str() ) >> 8 );
1607 } catch( ... ) {
1608 SYS_ASSERT( false, chain_type_exception, "Could not convert ${desc} string '${str}' to any of the following: "
1609 "uint64_t, valid name, or valid symbol (with or without the precision)",
1610 ("desc", desc)("str", str));
1611 }
1612}

◆ convert_to_type() [5/5]

template<>
double sysio::chain_apis::convert_to_type ( const string & str,
const string & desc )

Definition at line 1585 of file chain_plugin.cpp.

1585 {
1586
1587 try {
1588 return boost::lexical_cast<uint64_t>(str.c_str(), str.size());
1589 } catch( ... ) { }
1590
1591 try {
1592 auto trimmed_str = str;
1593 boost::trim(trimmed_str);
1594 name s(trimmed_str);
1595 return s.to_uint64_t();
1596 } catch( ... ) { }
1597
1598 if (str.find(',') != string::npos) { // fix #6274 only match formats like 4,SYS
1599 try {
1600 auto symb = sysio::chain::symbol::from_string(str);
1601 return symb.value();
1602 } catch( ... ) { }
1603 }
1604
1605 try {
1606 return ( sysio::chain::string_to_symbol( 0, str.c_str() ) >> 8 );
1607 } catch( ... ) {
1608 SYS_ASSERT( false, chain_type_exception, "Could not convert ${desc} string '${str}' to any of the following: "
1609 "uint64_t, valid name, or valid symbol (with or without the precision)",
1610 ("desc", desc)("str", str));
1611 }
1612}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_abi()

abi_def sysio::chain_apis::get_abi ( const controller & db,
const name & account )

Definition at line 1664 of file chain_plugin.cpp.

1664 {
1665 const auto &d = db.db();
1666 const account_object *code_accnt = d.find<account_object, by_name>(account);
1667 SYS_ASSERT(code_accnt != nullptr, chain::account_query_exception, "Fail to retrieve account for ${account}", ("account", account) );
1668 abi_def abi;
1669 abi_serializer::to_abi(code_accnt->abi, abi);
1670 return abi;
1671}
const chainbase::database & db() const
CK_ULONG d
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_global_row()

fc::variant sysio::chain_apis::get_global_row ( const database & db,
const abi_def & abi,
const abi_serializer & abis,
const fc::microseconds & abi_serializer_max_time_us,
bool shorten_abi_errors )

Definition at line 1848 of file chain_plugin.cpp.

1848 {
1849 const auto table_type = get_table_type(abi, "global"_n);
1850 SYS_ASSERT(table_type == read_only::KEYi64, chain::contract_table_query_exception, "Invalid table type ${type} for table global", ("type",table_type));
1851
1852 const auto* const table_id = db.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple(config::system_account_name, config::system_account_name, "global"_n));
1853 SYS_ASSERT(table_id, chain::contract_table_query_exception, "Missing table global");
1854
1855 const auto& kv_index = db.get_index<key_value_index, by_scope_primary>();
1856 const auto it = kv_index.find(boost::make_tuple(table_id->id, "global"_n.to_uint64_t()));
1857 SYS_ASSERT(it != kv_index.end(), chain::contract_table_query_exception, "Missing row in table global");
1858
1859 vector<char> data;
1860 read_only::copy_inline_row(*it, data);
1861 return abis.binary_to_variant(abis.get_table_type("global"_n), data, abi_serializer::create_yield_function( abi_serializer_max_time_us ), shorten_abi_errors );
1862}
const generic_index< MultiIndexType > & get_index() const
const ObjectType * find(CompatibleKey &&key) const
The table_id_object class tracks the mapping of (scope, code, table) to an opaque identifier.
string get_table_type(const abi_def &abi, const name &table_name)
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
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_table_type()

string sysio::chain_apis::get_table_type ( const abi_def & abi,
const name & table_name )

Definition at line 1673 of file chain_plugin.cpp.

1673 {
1674 for( const auto& t : abi.tables ) {
1675 if( t.name == table_name ){
1676 return t.index_type;
1677 }
1678 }
1679 SYS_ASSERT( false, chain::contract_table_query_exception, "Table ${table} is not specified in the ABI", ("table",table_name) );
1680}
Immutable except for fc::from_variant.
Definition name.hpp:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ itoh()

template<typename I >
std::string sysio::chain_apis::itoh ( I n,
size_t hlen = sizeof(I)<<1 )

Definition at line 1408 of file chain_plugin.cpp.

1408 {
1409 static const char* digits = "0123456789abcdef";
1410 std::string r(hlen, '0');
1411 for(size_t i = 0, j = (hlen - 1) * 4 ; i < hlen; ++i, j -= 4)
1412 r[i] = digits[(n>>j) & 0x0f];
1413 return r;
1414}
const mie::Vuint & r
Definition bn.cpp:28
uint16_t j
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_resolver()

auto sysio::chain_apis::make_resolver ( const controller & control,
abi_serializer::yield_function_t yield )

Definition at line 1964 of file chain_plugin.cpp.

1964 {
1965 return resolver_factory::make(control, std::move( yield ));
1966}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ dec

const char sysio::chain_apis::dec[] = "dec"
constexpr

Definition at line 700 of file chain_plugin.hpp.

◆ float128

const char sysio::chain_apis::float128[] = "float128"
constexpr

Definition at line 697 of file chain_plugin.hpp.

◆ float64

const char sysio::chain_apis::float64[] = "float64"
constexpr

Definition at line 696 of file chain_plugin.hpp.

◆ hex

const char sysio::chain_apis::hex[] = "hex"
constexpr

Definition at line 701 of file chain_plugin.hpp.

◆ i128

const char sysio::chain_apis::i128[] = "i128"
constexpr

Definition at line 694 of file chain_plugin.hpp.

◆ i256

const char sysio::chain_apis::i256[] = "i256"
constexpr

Definition at line 695 of file chain_plugin.hpp.

◆ i64

const char sysio::chain_apis::i64[] = "i64"
constexpr

Definition at line 693 of file chain_plugin.hpp.

◆ ripemd160

const char sysio::chain_apis::ripemd160[] = "ripemd160"
constexpr

Definition at line 699 of file chain_plugin.hpp.

◆ sha256

const char sysio::chain_apis::sha256[] = "sha256"
constexpr

Definition at line 698 of file chain_plugin.hpp.