diff --git a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp index 6ecf28e05c5..61b9662d4ed 100644 --- a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp +++ b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp @@ -112,14 +112,15 @@ datastream& operator<<(datastream& ds, const history_serial_wrapper -datastream& operator<<(datastream& ds, const history_serial_wrapper& obj) { +datastream& operator<<(datastream& ds, + const history_serial_wrapper& obj) { fc::raw::pack(ds, fc::unsigned_int(0)); fc::raw::pack(ds, as_type(obj.obj.name.value)); fc::raw::pack(ds, as_type(obj.obj.is_privileged())); fc::raw::pack(ds, as_type(obj.obj.last_code_update)); bool has_code = obj.obj.code_hash != eosio::chain::digest_type(); fc::raw::pack(ds, has_code); - if(has_code) { + if (has_code) { fc::raw::pack(ds, as_type(obj.obj.vm_type)); fc::raw::pack(ds, as_type(obj.obj.vm_version)); fc::raw::pack(ds, as_type(obj.obj.code_hash)); @@ -133,7 +134,6 @@ datastream& operator<<(datastream& ds, const history_serial_wrapper(obj.obj.vm_type)); fc::raw::pack(ds, as_type(obj.obj.vm_version)); fc::raw::pack(ds, as_type(obj.obj.code_hash)); - fc::raw::pack(ds, as_type(obj.obj.code_ref_count)); fc::raw::pack(ds, as_type(obj.obj.code)); return ds; } @@ -548,7 +548,8 @@ datastream& operator<<(datastream& fc::raw::pack(ds, bool(obj.obj.account_ram_delta)); if (obj.obj.account_ram_delta) { - fc::raw::pack(ds, make_history_serial_wrapper(obj.db, as_type(*obj.obj.account_ram_delta))); + fc::raw::pack( + ds, make_history_serial_wrapper(obj.db, as_type(*obj.obj.account_ram_delta))); } fc::optional e; diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index 738d31dfcd6..887044a5f28 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -53,6 +53,54 @@ static bytes zlib_compress_bytes(bytes in) { return out; } +template +bool include_delta(const T& old, const T& curr) { + return true; +} + +bool include_delta(const eosio::chain::table_id_object& old, const eosio::chain::table_id_object& curr) { + return old.payer != curr.payer; +} + +bool include_delta(const eosio::chain::resource_limits::resource_limits_object& old, + const eosio::chain::resource_limits::resource_limits_object& curr) { + return // + old.net_weight != curr.net_weight || // + old.cpu_weight != curr.cpu_weight || // + old.ram_bytes != curr.ram_bytes; +} + +bool include_delta(const eosio::chain::resource_limits::resource_limits_state_object& old, + const eosio::chain::resource_limits::resource_limits_state_object& curr) { + return // + old.average_block_net_usage.last_ordinal != curr.average_block_net_usage.last_ordinal || // + old.average_block_net_usage.value_ex != curr.average_block_net_usage.value_ex || // + old.average_block_net_usage.consumed != curr.average_block_net_usage.consumed || // + old.average_block_cpu_usage.last_ordinal != curr.average_block_cpu_usage.last_ordinal || // + old.average_block_cpu_usage.value_ex != curr.average_block_cpu_usage.value_ex || // + old.average_block_cpu_usage.consumed != curr.average_block_cpu_usage.consumed || // + old.total_net_weight != curr.total_net_weight || // + old.total_cpu_weight != curr.total_cpu_weight || // + old.total_ram_bytes != curr.total_ram_bytes || // + old.virtual_net_limit != curr.virtual_net_limit || // + old.virtual_cpu_limit != curr.virtual_cpu_limit; +} + +bool include_delta(const eosio::chain::account_metadata_object& old, + const eosio::chain::account_metadata_object& curr) { + return // + old.name.value != curr.name.value || // + old.is_privileged() != curr.is_privileged() || // + old.last_code_update != curr.last_code_update || // + old.vm_type != curr.vm_type || // + old.vm_version != curr.vm_version || // + old.code_hash != curr.code_hash; +} + +bool include_delta(const eosio::chain::code_object& old, const eosio::chain::code_object& curr) { // + return false; +} + struct state_history_plugin_impl : std::enable_shared_from_this { chain_plugin* chain_plug = nullptr; fc::optional trace_log; @@ -453,7 +501,8 @@ struct state_history_plugin_impl : std::enable_shared_from_this