MCPcopy Create free account
hub / github.com/bitshares/bitshares-core / pop_commit

Method pop_commit

libraries/db/undo_database.cpp:264–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void undo_database::pop_commit()
265{
266 FC_ASSERT( _active_sessions == 0 );
267 FC_ASSERT( !_stack.empty() );
268
269 disable();
270 try {
271 auto& state = _stack.back();
272
273 for( auto& item : state.old_values )
274 {
275 _db.modify( _db.get_object( item.second->id ), [&]( object& obj ){ obj.move_from( *item.second ); } );
276 }
277
278 for( auto ritr = state.new_ids.begin(); ritr != state.new_ids.end(); ++ritr )
279 {
280 _db.remove( _db.get_object(*ritr) );
281 }
282
283 for( auto& item : state.old_index_next_ids )
284 {
285 _db.get_mutable_index( item.first.space(), item.first.type() ).set_next_id( item.second );
286 }
287
288 for( auto& item : state.removed )
289 _db.insert( std::move(*item.second) );
290
291 _stack.pop_back();
292 }
293 catch ( const fc::exception& e )
294 {
295 elog( "error popping commit ${e}", ("e", e.to_detail_string() ) );
296 enable();
297 throw;
298 }
299 enable();
300}
301const undo_state& undo_database::head()const
302{
303 FC_ASSERT( !_stack.empty() );

Callers 1

Calls 9

move_fromMethod · 0.80
set_next_idMethod · 0.80
spaceMethod · 0.80
modifyMethod · 0.45
get_objectMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
removeMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected