Skip to content

Commit

Permalink
Merge pull request cryptonomex#689 from cifer-lee/issue121
Browse files Browse the repository at this point in the history
Fix cryptonomex#436 object_database created outside of witness data directory
  • Loading branch information
abitmore authored Feb 28, 2018
2 parents 68a5390 + bb30f3f commit 4e591a6
Show file tree
Hide file tree
Showing 2 changed files with 15 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;
}

} }
9 changes: 9 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,15 @@ 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, and
* database::close() has not been called, or failed during execution.
*/
bool _opened = false;
};

namespace detail
Expand Down

0 comments on commit 4e591a6

Please sign in to comment.