Skip to content

Commit

Permalink
Fix #436 object_database created outside of witness data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
cifer authored and xeroc committed Mar 21, 2018
1 parent b0dff76 commit d3b6a66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/chain/db_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ void database::reindex( fc::path data_dir )
void database::wipe(const fc::path& data_dir, bool include_blocks)
{
ilog("Wiping database", ("include_blocks", include_blocks));
close();
if (_opened) {
close();
}
object_database::wipe(data_dir);
if( include_blocks )
fc::remove_all( data_dir / "database" );
Expand Down Expand Up @@ -171,6 +173,7 @@ void database::open(
("last_block->id", last_block)("head_block_id",head_block_num()) );
reindex( data_dir );
}
_opened = true;
}
FC_CAPTURE_LOG_AND_RETHROW( (data_dir) )
}
Expand Down Expand Up @@ -214,6 +217,8 @@ void database::close(bool rewind)
_block_id_to_block.close();

_fork_db.reset();

_opened = false;
}

} }
8 changes: 8 additions & 0 deletions libraries/chain/include/graphene/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ namespace graphene { namespace chain {
flat_map<uint32_t,block_id_type> _checkpoints;

node_property_object _node_property_object;

/**
* Whether database is successfully opened or not.
*
* The database is considered open when there's no exception
* or assertion fail during database::open() method.
*/
bool _opened = false;
};

namespace detail
Expand Down

0 comments on commit d3b6a66

Please sign in to comment.