58 {
59 std::vector<table_delta> deltas;
61 std::map<uint64_t, const chain::table_id_object*> removed_table_id;
62 for (auto& rem : table_id_index.last_undo_session().removed_values)
63 removed_table_id[rem.id._id] = &rem;
64
66 auto obj = table_id_index.find(tid);
67 if (obj)
68 return *obj;
69 auto it = removed_table_id.find(tid);
70 SYS_ASSERT(it != removed_table_id.end(), chain::plugin_exception,
"can not found table id ${tid}", (
"tid", tid));
71 return *it->second;
72 };
73
75 auto pack_contract_row = [&](auto& row) {
77 };
78
79 auto process_table = [&](
auto*
name,
auto& index,
auto& pack_row) {
80 if (full_snapshot) {
81 if (index.indices().empty())
82 return;
83 deltas.push_back({});
84 auto& delta = deltas.back();
86 for (auto& row : index.indices())
87 delta.rows.obj.emplace_back(true, pack_row(row));
88 } else {
89 auto undo = index.last_undo_session();
90 if (undo.old_values.empty() && undo.new_values.empty() && undo.removed_values.empty())
91 return;
92 deltas.push_back({});
93 auto& delta = deltas.back();
95 for (auto& old : undo.old_values) {
96 auto& row = index.get(old.id);
98 delta.rows.obj.emplace_back(true, pack_row(row));
99 }
100 for (auto& old : undo.removed_values)
101 delta.rows.obj.emplace_back(false, pack_row(old));
102 for (auto& row : undo.new_values) {
103 delta.rows.obj.emplace_back(true, pack_row(row));
104 }
105 }
106 };
107
108 process_table(
"account", db.
get_index<chain::account_index>(), pack_row);
109 process_table(
"account_metadata", db.
get_index<chain::account_metadata_index>(), pack_row);
110 process_table(
"code", db.
get_index<chain::code_index>(), pack_row);
111
112 process_table(
"contract_table", db.
get_index<chain::table_id_multi_index>(), pack_row);
113 process_table(
"contract_row", db.
get_index<chain::key_value_index>(), pack_contract_row);
114 process_table(
"contract_index64", db.
get_index<chain::index64_index>(), pack_contract_row);
115 process_table(
"contract_index128", db.
get_index<chain::index128_index>(), pack_contract_row);
116 process_table(
"contract_index256", db.
get_index<chain::index256_index>(), pack_contract_row);
117 process_table(
"contract_index_double", db.
get_index<chain::index_double_index>(), pack_contract_row);
118 process_table(
"contract_index_long_double", db.
get_index<chain::index_long_double_index>(), pack_contract_row);
119
120 process_table(
"global_property", db.
get_index<chain::global_property_multi_index>(), pack_row);
121 process_table(
"generated_transaction", db.
get_index<chain::generated_transaction_multi_index>(), pack_row);
122 process_table(
"protocol_state", db.
get_index<chain::protocol_state_multi_index>(), pack_row);
123
124 process_table(
"permission", db.
get_index<chain::permission_index>(), pack_row);
125 process_table(
"permission_link", db.
get_index<chain::permission_link_index>(), pack_row);
126
127 process_table(
"resource_limits", db.
get_index<chain::resource_limits::resource_limits_index>(), pack_row);
128 process_table(
"resource_usage", db.
get_index<chain::resource_limits::resource_usage_index>(), pack_row);
129 process_table(
"resource_limits_state", db.
get_index<chain::resource_limits::resource_limits_state_index>(),
130 pack_row);
131 process_table(
"resource_limits_config", db.
get_index<chain::resource_limits::resource_limits_config_index>(),
132 pack_row);
133
134 return deltas;
135}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
const generic_index< MultiIndexType > & get_index() const
The table_id_object class tracks the mapping of (scope, code, table) to an opaque identifier.
void pack(Stream &s, const std::deque< T > &value)
chainbase::shared_multi_index_container< table_id_object, indexed_by< ordered_unique< tag< by_id >, member< table_id_object, table_id_object::id_type, &table_id_object::id > >, ordered_unique< tag< by_code_scope_table >, composite_key< table_id_object, member< table_id_object, account_name, &table_id_object::code >, member< table_id_object, scope_name, &table_id_object::scope >, member< table_id_object, table_name, &table_id_object::table > > > > > table_id_multi_index
bool include_delta(const T &old, const T &curr)
history_context_wrapper< std::decay_t< P >, std::decay_t< T > > make_history_context_wrapper(const chainbase::database &db, const P &context, const T &obj)
history_serial_wrapper< std::decay_t< T > > make_history_serial_wrapper(const chainbase::database &db, const T &obj)
unsigned __int64 uint64_t