Merge pull request #873 from pmconrad/585_fix_history_ids
Fix history ids
This commit is contained in:
parent
38f28a508b
commit
f030fcd688
2 changed files with 13 additions and 2 deletions
|
|
@ -90,10 +90,21 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b
|
||||||
{
|
{
|
||||||
graphene::chain::database& db = database();
|
graphene::chain::database& db = database();
|
||||||
const vector<optional< operation_history_object > >& hist = db.get_applied_operations();
|
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 ) {
|
for( const optional< operation_history_object >& o_op : hist ) {
|
||||||
optional <operation_history_object> oho;
|
optional <operation_history_object> oho;
|
||||||
|
|
||||||
auto create_oho = [&]() {
|
auto create_oho = [&]() {
|
||||||
|
is_first = false;
|
||||||
return optional<operation_history_object>(
|
return optional<operation_history_object>(
|
||||||
db.create<operation_history_object>([&](operation_history_object &h) {
|
db.create<operation_history_object>([&](operation_history_object &h) {
|
||||||
if (o_op.valid())
|
if (o_op.valid())
|
||||||
|
|
@ -109,7 +120,7 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b
|
||||||
};
|
};
|
||||||
|
|
||||||
if( !o_op.valid() ) {
|
if( !o_op.valid() ) {
|
||||||
_oho_index->use_next_id();
|
skip_oho_id();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
oho = create_oho();
|
oho = create_oho();
|
||||||
|
|
|
||||||
|
|
@ -591,4 +591,4 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue