@@ -206,7 +206,7 @@ namespace eosio {
206
206
207
207
void record_account_action ( account_name n, const base_action_trace& act ) {
208
208
auto & chain = chain_plug->chain ();
209
- auto & db = chain.db ();
209
+ chainbase::database & db = const_cast <chainbase::database&>( chain.db () ); // Override read-only access to state DB (highly unrecommended practice!)
210
210
211
211
const auto & idx = db.get_index <account_history_index, by_account_action_seq>();
212
212
auto itr = idx.lower_bound ( boost::make_tuple ( name (n.value +1 ), 0 ) );
@@ -227,7 +227,7 @@ namespace eosio {
227
227
228
228
void on_system_action ( const action_trace& at ) {
229
229
auto & chain = chain_plug->chain ();
230
- auto & db = chain.db ();
230
+ chainbase::database & db = const_cast <chainbase::database&>( chain.db () ); // Override read-only access to state DB (highly unrecommended practice!)
231
231
if ( at.act .name == N (newaccount) )
232
232
{
233
233
const auto create = at.act .data_as <chain::newaccount>();
@@ -256,7 +256,7 @@ namespace eosio {
256
256
if ( filter ( at ) ) {
257
257
// idump((fc::json::to_pretty_string(at)));
258
258
auto & chain = chain_plug->chain ();
259
- auto & db = chain.db ();
259
+ chainbase::database & db = const_cast <chainbase::database&>( chain.db () ); // Override read-only access to state DB (highly unrecommended practice!)
260
260
261
261
db.create <action_history_object>( [&]( auto & aho ) {
262
262
auto ps = fc::raw::pack_size ( at );
@@ -344,10 +344,12 @@ namespace eosio {
344
344
EOS_ASSERT ( my->chain_plug , chain::missing_chain_plugin_exception, " " );
345
345
auto & chain = my->chain_plug ->chain ();
346
346
347
- chain.db ().add_index <account_history_index>();
348
- chain.db ().add_index <action_history_index>();
349
- chain.db ().add_index <account_control_history_multi_index>();
350
- chain.db ().add_index <public_key_history_multi_index>();
347
+ chainbase::database& db = const_cast <chainbase::database&>( chain.db () ); // Override read-only access to state DB (highly unrecommended practice!)
348
+ // TODO: Use separate chainbase database for managing the state of the history_plugin (or remove deprecated history_plugin entirely)
349
+ db.add_index <account_history_index>();
350
+ db.add_index <action_history_index>();
351
+ db.add_index <account_control_history_multi_index>();
352
+ db.add_index <public_key_history_multi_index>();
351
353
352
354
my->applied_transaction_connection .emplace (
353
355
chain.applied_transaction .connect ( [&]( const transaction_trace_ptr& p ) {
0 commit comments