diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index b63802db..a7d3fefa 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -90,10 +90,21 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b { graphene::chain::database& db = database(); const vector >& hist = db.get_applied_operations(); + bool is_first = true; + auto skip_oho_id = [&is_first,&db,this]() { + if( is_first && db._undo_db.enabled() ) // this ensures that the current id is rolled back on undo + { + db.remove( db.create( []( operation_history_object& obj) {} ) ); + is_first = false; + } + else + _oho_index->use_next_id(); + }; for( const optional< operation_history_object >& o_op : hist ) { optional oho; auto create_oho = [&]() { + is_first = false; return optional( db.create([&](operation_history_object &h) { if (o_op.valid()) @@ -109,7 +120,7 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b }; if( !o_op.valid() ) { - _oho_index->use_next_id(); + skip_oho_id(); continue; } oho = create_oho(); diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 4edccce5..943b8265 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -595,4 +595,4 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { } } -BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file +BOOST_AUTO_TEST_SUITE_END()