File tree 2 files changed +24
-3
lines changed
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,17 @@ void account_history_plugin_impl::update_account_histories( const signed_block&
82
82
{
83
83
graphene::chain::database& db = database ();
84
84
const vector<optional< operation_history_object > >& hist = db.get_applied_operations ();
85
+ bool is_first = true ;
86
+ auto skip_oho_id = [&is_first,&db,this ]() {
87
+ if ( is_first && db._undo_db .enabled () ) // this ensures that the current id is rolled back on undo
88
+ {
89
+ db.remove ( db.create <operation_history_object>( []( operation_history_object& obj) {} ) );
90
+ is_first = false ;
91
+ }
92
+ else
93
+ _oho_index->use_next_id ();
94
+ };
95
+
85
96
for ( const optional< operation_history_object >& o_op : hist )
86
97
{
87
98
optional<operation_history_object> oho;
@@ -105,7 +116,7 @@ void account_history_plugin_impl::update_account_histories( const signed_block&
105
116
{
106
117
// Note: the 2nd and 3rd checks above are for better performance, when the db is not clean,
107
118
// they will break consistency of account_stats.total_ops and removed_ops and most_recent_op
108
- _oho_index-> use_next_id ();
119
+ skip_oho_id ();
109
120
continue ;
110
121
}
111
122
else if ( !_partial_operations )
@@ -178,7 +189,7 @@ void account_history_plugin_impl::update_account_histories( const signed_block&
178
189
}
179
190
}
180
191
if (_partial_operations && ! oho.valid ())
181
- _oho_index-> use_next_id ();
192
+ skip_oho_id ();
182
193
}
183
194
}
184
195
Original file line number Diff line number Diff line change @@ -90,6 +90,16 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b
90
90
{
91
91
graphene::chain::database& db = database ();
92
92
const vector<optional< operation_history_object > >& hist = db.get_applied_operations ();
93
+ bool is_first = true ;
94
+ auto skip_oho_id = [&is_first,&db,this ]() {
95
+ if ( is_first && db._undo_db .enabled () ) // this ensures that the current id is rolled back on undo
96
+ {
97
+ db.remove ( db.create <operation_history_object>( []( operation_history_object& obj) {} ) );
98
+ is_first = false ;
99
+ }
100
+ else
101
+ _oho_index->use_next_id ();
102
+ };
93
103
for ( const optional< operation_history_object >& o_op : hist ) {
94
104
optional <operation_history_object> oho;
95
105
@@ -109,7 +119,7 @@ void elasticsearch_plugin_impl::update_account_histories( const signed_block& b
109
119
};
110
120
111
121
if ( !o_op.valid () ) {
112
- _oho_index-> use_next_id ();
122
+ skip_oho_id ();
113
123
continue ;
114
124
}
115
125
oho = create_oho ();
You can’t perform that action at this time.
0 commit comments