database.hpp: Make open() non-templated, move implementation out of header
This commit is contained in:
parent
5d3bd282c8
commit
430bbe42ab
2 changed files with 28 additions and 21 deletions
|
|
@ -71,6 +71,30 @@ void database::wipe(const fc::path& data_dir, bool include_blocks)
|
|||
fc::remove_all( data_dir / "database" );
|
||||
}
|
||||
|
||||
void database::open(
|
||||
const fc::path& data_dir,
|
||||
std::function<genesis_state_type()> genesis_loader )
|
||||
{
|
||||
try
|
||||
{
|
||||
object_database::open(data_dir);
|
||||
|
||||
_block_id_to_block.open(data_dir / "database" / "block_num_to_block");
|
||||
|
||||
if( !find(global_property_id_type()) )
|
||||
init_genesis(genesis_loader());
|
||||
|
||||
_pending_block.previous = head_block_id();
|
||||
_pending_block.timestamp = head_block_time();
|
||||
|
||||
auto last_block = _block_id_to_block.last();
|
||||
if( last_block.valid() )
|
||||
_fork_db.start_block( *last_block );
|
||||
}
|
||||
FC_CAPTURE_AND_RETHROW( (data_dir) )
|
||||
}
|
||||
|
||||
|
||||
void database::close(uint32_t blocks_to_rewind)
|
||||
{
|
||||
_pending_block_session.reset();
|
||||
|
|
|
|||
|
|
@ -103,8 +103,10 @@ namespace graphene { namespace chain {
|
|||
* @param data_dir Path to open or create database in
|
||||
* @param genesis_loader A callable object which returns the genesis state to initialize new databases on
|
||||
*/
|
||||
template<typename F>
|
||||
void open(const fc::path& data_dir, F&& genesis_loader);
|
||||
void open(
|
||||
const fc::path& data_dir,
|
||||
std::function<genesis_state_type()> genesis_loader );
|
||||
|
||||
/**
|
||||
* @brief Rebuild object graph from block history and open detabase
|
||||
*
|
||||
|
|
@ -523,23 +525,4 @@ namespace graphene { namespace chain {
|
|||
}
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void database::open(const fc::path& data_dir, F&& genesis_loader)
|
||||
{ try {
|
||||
object_database::open(data_dir);
|
||||
|
||||
_block_id_to_block.open(data_dir / "database" / "block_num_to_block");
|
||||
|
||||
if( !find(global_property_id_type()) )
|
||||
init_genesis(genesis_loader());
|
||||
|
||||
_pending_block.previous = head_block_id();
|
||||
_pending_block.timestamp = head_block_time();
|
||||
|
||||
auto last_block= _block_id_to_block.last();
|
||||
if( last_block.valid() )
|
||||
_fork_db.start_block( *last_block );
|
||||
|
||||
} FC_CAPTURE_AND_RETHROW( (data_dir) ) }
|
||||
|
||||
} }
|
||||
|
|
|
|||
Loading…
Reference in a new issue