#pragma once
#include "producer_schedule.hpp"
#include "system.hpp"
#include "../../core/eosio/crypto.hpp"
#include "../../core/eosio/name.hpp"
#include "../../core/eosio/serialize.hpp"
namespace eosio {
namespace internal_use_do_not_use {
extern "C" {
__attribute__((eosio_wasm_import))
bool is_privileged( uint64_t account );
__attribute__((eosio_wasm_import))
void get_resource_limits( uint64_t account, int64_t* ram_bytes, int64_t* net_weight, int64_t* cpu_weight );
__attribute__((eosio_wasm_import))
void set_resource_limits( uint64_t account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight );
__attribute__((eosio_wasm_import))
void set_privileged( uint64_t account, bool is_priv );
__attribute__((eosio_wasm_import))
void set_blockchain_parameters_packed( char* data, uint32_t datalen );
__attribute__((eosio_wasm_import))
uint32_t get_blockchain_parameters_packed( char* data, uint32_t datalen );
__attribute((eosio_wasm_import))
int64_t set_proposed_producers( char*, uint32_t );
__attribute__((eosio_wasm_import))
void preactivate_feature( const capi_checksum256* feature_digest );
__attribute__((eosio_wasm_import))
int64_t set_proposed_producers_ex( uint64_t producer_data_format, char *producer_data, uint32_t producer_data_size );
}
}
struct blockchain_parameters {
uint64_t max_block_net_usage;
uint32_t target_block_net_usage_pct;
uint32_t max_transaction_net_usage;
uint32_t base_per_transaction_net_usage;
uint32_t net_usage_leeway;
uint32_t context_free_discount_net_usage_num;
uint32_t context_free_discount_net_usage_den;
uint32_t max_block_cpu_usage;
uint32_t target_block_cpu_usage_pct;
uint32_t max_transaction_cpu_usage;
uint32_t min_transaction_cpu_usage;
uint32_t max_transaction_lifetime;
uint32_t deferred_trx_expiration_window;
uint32_t max_transaction_delay;
uint32_t max_inline_action_size;
uint16_t max_inline_action_depth;
uint16_t max_authority_depth;
EOSLIB_SERIALIZE( blockchain_parameters,
(max_block_net_usage)(target_block_net_usage_pct)
(max_transaction_net_usage)(base_per_transaction_net_usage)(net_usage_leeway)
(context_free_discount_net_usage_num)(context_free_discount_net_usage_den)
(max_block_cpu_usage)(target_block_cpu_usage_pct)
(max_transaction_cpu_usage)(min_transaction_cpu_usage)
(max_transaction_lifetime)(deferred_trx_expiration_window)(max_transaction_delay)
(max_inline_action_size)(max_inline_action_depth)(max_authority_depth)
)
};
void set_blockchain_parameters(const eosio::blockchain_parameters& params);
void get_blockchain_parameters(eosio::blockchain_parameters& params);
inline void get_resource_limits( name account, int64_t& ram_bytes, int64_t& net_weight, int64_t& cpu_weight ) {
internal_use_do_not_use::get_resource_limits( account.value, &ram_bytes, &net_weight, &cpu_weight );
}
inline void set_resource_limits( name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight ) {
internal_use_do_not_use::set_resource_limits( account.value, ram_bytes, net_weight, cpu_weight );
}
std::optional<uint64_t> set_proposed_producers( const std::vector<producer_key>& prods );
inline std::optional<uint64_t> set_proposed_producers( const std::vector<producer_authority>& prods ) {
auto packed_prods = eosio::pack( prods );
int64_t ret = internal_use_do_not_use::set_proposed_producers_ex(1, (char*)packed_prods.data(), packed_prods.size());
if (ret >= 0)
return static_cast<uint64_t>(ret);
return {};
}
inline bool is_privileged( name account ) {
return internal_use_do_not_use::is_privileged( account.value );
}
inline void set_privileged( name account, bool is_priv ) {
internal_use_do_not_use::set_privileged( account.value, is_priv );
}
inline void preactivate_feature( const checksum256& feature_digest ) {
auto feature_digest_data = feature_digest.extract_as_byte_array();
internal_use_do_not_use::preactivate_feature(
reinterpret_cast<const internal_use_do_not_use::capi_checksum256*>( feature_digest_data.data() )
);
}
}