提交 908ad7ca 编写于 作者: T Todd Fleming

state history plugin: cleanup

上级 73fd5bff
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <fstream>
#include <stdint.h>
#include <eosio/chain/exceptions.hpp>
#include <fc/log/logger.hpp>
namespace eosio {
/*
* *.log:
* +---------+----------------+-----------+------------------+-----+---------+----------------+
* | Entry i | Pos of Entry i | Entry i+1 | Pos of Entry i+1 | ... | Entry z | Pos of Entry z |
* +---------+----------------+-----------+------------------+-----+---------+----------------+
*
* *.index:
* +----------------+------------------+-----+----------------+
* | Pos of Entry i | Pos of Entry i+1 | ... | Pos of Entry z |
* +----------------+------------------+-----+----------------+
*
* each entry:
* uint32_t block_num
* uint64_t size of payload
* uint8_t version
* payload
*
* irreversible_state payload:
* uint32_t size of deltas
* char[] deltas
*/
struct history_log_header {
uint32_t block_num = 0;
uint64_t payload_size = 0;
uint16_t version = 0;
};
struct history_log {
const char* const name = "";
std::fstream log;
std::fstream index;
uint32_t begin_block = 0;
uint32_t end_block = 0;
void open_log(const std::string& filename) {
log.open(filename, std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::app);
uint64_t size = log.tellg();
if (size >= sizeof(history_log_header)) {
history_log_header header;
log.seekg(0);
log.read((char*)&header, sizeof(header));
EOS_ASSERT(header.version == 0 && sizeof(header) + header.payload_size + sizeof(uint64_t) <= size,
chain::plugin_exception, "corrupt ${name}.log (1)", ("name", name));
begin_block = header.block_num;
uint64_t end_pos;
log.seekg(size - sizeof(end_pos));
log.read((char*)&end_pos, sizeof(end_pos));
EOS_ASSERT(end_pos <= size && end_pos + sizeof(header) <= size, chain::plugin_exception,
"corrupt ${name}.log (2)", ("name", name));
log.seekg(end_pos);
log.read((char*)&header, sizeof(header));
EOS_ASSERT(end_pos + sizeof(header) + header.payload_size + sizeof(uint64_t) == size, chain::plugin_exception,
"corrupt ${name}.log (3)", ("name", name));
end_block = header.block_num + 1;
EOS_ASSERT(begin_block < end_block, chain::plugin_exception, "corrupt ${name}.log (4)", ("name", name));
ilog("${name}.log has blocks ${b}-${e}", ("name", name)("b", begin_block)("e", end_block - 1));
} else {
EOS_ASSERT(!size, chain::plugin_exception, "corrupt ${name}.log (5)", ("name", name));
ilog("${name}.log is empty", ("name", name));
}
}
void open_index(const std::string& filename) {
index.open(filename, std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::app);
if (index.tellg() == (end_block - begin_block) * sizeof(uint64_t))
return;
ilog("Regenerate ${name}.index", ("name", name));
index.close();
index.open(filename, std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc);
log.seekg(0, std::ios_base::end);
uint64_t size = log.tellg();
uint64_t pos = 0;
while (pos < size) {
index.write((char*)&pos, sizeof(pos));
history_log_header header;
EOS_ASSERT(pos + sizeof(header) <= size, chain::plugin_exception, "corrupt ${name}.log (6)", ("name", name));
log.seekg(pos);
log.read((char*)&header, sizeof(header));
uint64_t suffix_pos = pos + sizeof(header) + header.payload_size;
uint64_t suffix;
EOS_ASSERT(suffix_pos + sizeof(suffix) <= size, chain::plugin_exception, "corrupt ${name}.log (7)",
("name", name));
log.seekg(suffix_pos);
log.read((char*)&suffix, sizeof(suffix));
// ilog("block ${b} at ${pos}-${end} suffix=${suffix} file_size=${fs}",
// ("b", header.block_num)("pos", pos)("end", suffix_pos + sizeof(suffix))("suffix", suffix)("fs", size));
EOS_ASSERT(suffix == pos, chain::plugin_exception, "corrupt ${name}.log (8)", ("name", name));
pos = suffix_pos + sizeof(suffix);
}
}
template <typename F>
void write_entry(history_log_header header, F write_payload) {
EOS_ASSERT(begin_block == end_block || header.block_num == end_block, chain::plugin_exception,
"writing unexpected block_num to ${name}.log", ("name", name));
log.seekg(0, std::ios_base::end);
uint64_t pos = log.tellg();
log.write((char*)&header, sizeof(header));
write_payload(log);
uint64_t end = log.tellg();
EOS_ASSERT(end == pos + sizeof(header) + header.payload_size, chain::plugin_exception,
"wrote payload with incorrect size to ${name}.log", ("name", name));
log.write((char*)&pos, sizeof(pos));
index.seekg(0, std::ios_base::end);
index.write((char*)&pos, sizeof(pos));
if (begin_block == end_block)
begin_block = header.block_num;
end_block = header.block_num + 1;
}
// returns stream positioned at payload
std::fstream& get_entry(uint32_t block_num, history_log_header& header) {
EOS_ASSERT(block_num >= begin_block && block_num < end_block, chain::plugin_exception,
"read non-existing block in ${name}.log", ("name", name));
uint64_t pos;
index.seekg((block_num - begin_block) * sizeof(pos));
index.read((char*)&pos, sizeof(pos));
log.seekg(pos);
log.read((char*)&header, sizeof(header));
return log;
}
}; // history_log
} // namespace eosio
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <eosio/chain/account_object.hpp>
#include <eosio/chain/block_summary_object.hpp>
#include <eosio/chain/controller.hpp>
#include <eosio/chain/generated_transaction_object.hpp>
#include <eosio/chain/global_property_object.hpp>
#include <eosio/chain/permission_link_object.hpp>
#include <eosio/chain/permission_object.hpp>
#include <eosio/chain/resource_limits.hpp>
#include <eosio/chain/resource_limits_private.hpp>
#include <eosio/chain/trace.hpp>
#include <eosio/chain/transaction_object.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
template <typename T>
struct history_serial_wrapper {
const T& obj;
};
template <typename T>
history_serial_wrapper<T> make_history_serial_wrapper(const T& obj) {
return {obj};
}
namespace fc {
template <typename T>
const T& as_type(const T& x) {
return x;
}
template <typename ST, typename T>
void serialize_shared_vector(datastream<ST>& ds, const T& v) {
fc::raw::pack(ds, unsigned_int(v.size()));
for (auto& x : v)
ds << make_history_serial_wrapper(x);
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::account_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.value));
fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_type));
fc::raw::pack(ds, as_type<uint8_t>(obj.obj.vm_version));
fc::raw::pack(ds, as_type<bool>(obj.obj.privileged));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.last_code_update));
fc::raw::pack(ds, as_type<eosio::chain::digest_type>(obj.obj.code_version));
fc::raw::pack(ds, as_type<eosio::chain::block_timestamp_type>(obj.obj.creation_date));
fc::raw::pack(ds, as_type<eosio::chain::shared_string>(obj.obj.code));
fc::raw::pack(ds, as_type<eosio::chain::shared_string>(obj.obj.abi));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::account_sequence_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.recv_sequence));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.auth_sequence));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.code_sequence));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.abi_sequence));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::table_id_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.code.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.scope.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.table.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.payer.value));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.count));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::key_value_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.t_id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.primary_key));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.payer.value));
fc::raw::pack(ds, as_type<eosio::chain::shared_string>(obj.obj.value));
return ds;
}
template <typename ST, typename T>
void serialize_secondary_index_data(datastream<ST>& ds, const T& obj) {
fc::raw::pack(ds, obj);
}
template <typename ST>
void serialize_secondary_index_data(datastream<ST>& ds, const float64_t& obj) {
uint64_t i;
memcpy(&i, &obj, sizeof(i));
fc::raw::pack(ds, i);
}
template <typename ST>
void serialize_secondary_index_data(datastream<ST>& ds, const float128_t& obj) {
__uint128_t i;
memcpy(&i, &obj, sizeof(i));
fc::raw::pack(ds, i);
}
template <typename ST>
void serialize_secondary_index_data(datastream<ST>& ds, const eosio::chain::key256_t& obj) {
fc::raw::pack(ds, obj[0]);
fc::raw::pack(ds, obj[1]);
}
template <typename ST, typename T>
datastream<ST>& serialize_secondary_index(datastream<ST>& ds, const T& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.t_id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.primary_key));
fc::raw::pack(ds, as_type<uint64_t>(obj.payer.value));
serialize_secondary_index_data(ds, obj.secondary_key);
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::index64_object>& obj) {
return serialize_secondary_index(ds, obj.obj);
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::index128_object>& obj) {
return serialize_secondary_index(ds, obj.obj);
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::index256_object>& obj) {
return serialize_secondary_index(ds, obj.obj);
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::index_double_object>& obj) {
return serialize_secondary_index(ds, obj.obj);
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::index_long_double_object>& obj) {
return serialize_secondary_index(ds, obj.obj);
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::producer_key>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.producer_name.value));
fc::raw::pack(ds, as_type<eosio::chain::public_key_type>(obj.obj.block_signing_key));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::shared_producer_schedule_type>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.version));
serialize_shared_vector(ds, obj.obj.producers);
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::chain_config>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.max_block_net_usage));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.target_block_net_usage_pct));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_net_usage));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.base_per_transaction_net_usage));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.net_usage_leeway));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.context_free_discount_net_usage_num));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.context_free_discount_net_usage_den));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_block_cpu_usage));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.target_block_cpu_usage_pct));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_cpu_usage));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.min_transaction_cpu_usage));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_lifetime));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.deferred_trx_expiration_window));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_transaction_delay));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_inline_action_size));
fc::raw::pack(ds, as_type<uint16_t>(obj.obj.max_inline_action_depth));
fc::raw::pack(ds, as_type<uint16_t>(obj.obj.max_authority_depth));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::global_property_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<optional<eosio::chain::block_num_type>>(obj.obj.proposed_schedule_block_num));
fc::raw::pack(ds, make_history_serial_wrapper(
as_type<eosio::chain::shared_producer_schedule_type>(obj.obj.proposed_schedule)));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::chain_config>(obj.obj.configuration)));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::dynamic_global_property_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.global_action_sequence));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::block_summary_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<eosio::chain::block_id_type>(obj.obj.block_id));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::transaction_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<fc::time_point_sec>(obj.obj.expiration));
fc::raw::pack(ds, as_type<eosio::chain::transaction_id_type>(obj.obj.trx_id));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::generated_transaction_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<eosio::chain::transaction_id_type>(obj.obj.trx_id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.sender.value));
fc::raw::pack(ds, as_type<__uint128_t>(obj.obj.sender_id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.payer.value));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.delay_until));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.expiration));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.published));
fc::raw::pack(ds, as_type<eosio::chain::shared_string>(obj.obj.packed_trx));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::key_weight>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<eosio::chain::public_key_type>(obj.obj.key));
fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::permission_level>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.actor.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.permission.value));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::permission_level_weight>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::permission_level>(obj.obj.permission)));
fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::wait_weight>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.wait_sec));
fc::raw::pack(ds, as_type<uint16_t>(obj.obj.weight));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::shared_authority>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.threshold));
serialize_shared_vector(ds, obj.obj.keys);
serialize_shared_vector(ds, obj.obj.accounts);
serialize_shared_vector(ds, obj.obj.waits);
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper<eosio::chain::permission_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.usage_id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.parent._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.owner.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.name.value));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.last_updated));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::shared_authority>(obj.obj.auth)));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::permission_usage_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<fc::time_point>(obj.obj.last_used));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::permission_link_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.account.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.code.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.message_type.value));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.required_permission.value));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::resource_limits_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.owner.value));
fc::raw::pack(ds, as_type<bool>(obj.obj.pending));
fc::raw::pack(ds, as_type<int64_t>(obj.obj.net_weight));
fc::raw::pack(ds, as_type<int64_t>(obj.obj.cpu_weight));
fc::raw::pack(ds, as_type<int64_t>(obj.obj.ram_bytes));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::usage_accumulator>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.last_ordinal));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.value_ex));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.consumed));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::resource_usage_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.owner.value));
fc::raw::pack(
ds, make_history_serial_wrapper(as_type<eosio::chain::resource_limits::usage_accumulator>(obj.obj.net_usage)));
fc::raw::pack(
ds, make_history_serial_wrapper(as_type<eosio::chain::resource_limits::usage_accumulator>(obj.obj.cpu_usage)));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.ram_usage));
return ds;
}
template <typename ST>
datastream<ST>&
operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::resource_limits_state_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, make_history_serial_wrapper(
as_type<eosio::chain::resource_limits::usage_accumulator>(obj.obj.average_block_net_usage)));
fc::raw::pack(ds, make_history_serial_wrapper(
as_type<eosio::chain::resource_limits::usage_accumulator>(obj.obj.average_block_cpu_usage)));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.pending_net_usage));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.pending_cpu_usage));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.total_net_weight));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.total_cpu_weight));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.total_ram_bytes));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.virtual_net_limit));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.virtual_cpu_limit));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::ratio>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.numerator));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.denominator));
return ds;
}
template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::elastic_limit_parameters>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.target));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.max));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.periods));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.max_multiplier));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::resource_limits::ratio>(obj.obj.contract_rate)));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::resource_limits::ratio>(obj.obj.expand_rate)));
return ds;
}
template <typename ST>
datastream<ST>&
operator<<(datastream<ST>& ds,
const history_serial_wrapper<eosio::chain::resource_limits::resource_limits_config_object>& obj) {
fc::raw::pack(ds, fc::unsigned_int(0));
fc::raw::pack(ds, as_type<uint64_t>(obj.obj.id._id));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::resource_limits::elastic_limit_parameters>(
obj.obj.cpu_limit_parameters)));
fc::raw::pack(ds, make_history_serial_wrapper(as_type<eosio::chain::resource_limits::elastic_limit_parameters>(
obj.obj.net_limit_parameters)));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.account_cpu_usage_average_window));
fc::raw::pack(ds, as_type<uint32_t>(obj.obj.account_net_usage_average_window));
return ds;
};
} // namespace fc
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册