| 262 | } |
| 263 | |
| 264 | void 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 | } |
| 301 | const undo_state& undo_database::head()const |
| 302 | { |
| 303 | FC_ASSERT( !_stack.empty() ); |
no test coverage detected