Merge pull request #873 from pmconrad/585_fix_history_ids

Fix history ids
This commit is contained in:
Abit 2018-04-25 16:34:37 +02:00 committed by gladcow
parent 8d900a5276
commit e91e61e6cb
2 changed files with 13 additions and 2 deletions

View file

@ -90,10 +90,21 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b
{
graphene::chain::database& db = database();
const vector<optional< operation_history_object > >& 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>( []( operation_history_object& obj) {} ) );
is_first = false;
}
else
_oho_index->use_next_id();
};
for( const optional< operation_history_object >& o_op : hist ) {
optional <operation_history_object> oho;
auto create_oho = [&]() {
is_first = false;
return optional<operation_history_object>(
db.create<operation_history_object>([&](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();

View file

@ -595,4 +595,4 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) {
}
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()