mirror of
https://github.com/monero-project/monero.git
synced 2024-12-30 14:06:11 -05:00
blockchain_import: properly cleanup core/db on exit
This commit is contained in:
parent
8d6967be39
commit
2f9a5528a7
@ -692,18 +692,12 @@ int main(int argc, char* argv[])
|
|||||||
MINFO("bootstrap file path: " << import_file_path);
|
MINFO("bootstrap file path: " << import_file_path);
|
||||||
MINFO("database path: " << m_config_folder);
|
MINFO("database path: " << m_config_folder);
|
||||||
|
|
||||||
|
cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects
|
||||||
|
cryptonote::core core(&pr);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
// fake_core needed for verification to work when enabled.
|
|
||||||
//
|
|
||||||
// NOTE: don't need fake_core method of doing things when we're going to call
|
|
||||||
// BlockchainDB add_block() directly and have available the 3 block
|
|
||||||
// properties to do so. Both ways work, but fake core isn't necessary in that
|
|
||||||
// circumstance.
|
|
||||||
|
|
||||||
cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects
|
|
||||||
cryptonote::core core(&pr);
|
|
||||||
core.disable_dns_checkpoints(true);
|
core.disable_dns_checkpoints(true);
|
||||||
if (!core.init(vm, NULL))
|
if (!core.init(vm, NULL))
|
||||||
{
|
{
|
||||||
@ -731,23 +725,19 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
import_from_file(core, import_file_path, block_stop);
|
import_from_file(core, import_file_path, block_stop);
|
||||||
|
|
||||||
}
|
|
||||||
catch (const DB_ERROR& e)
|
|
||||||
{
|
|
||||||
std::cout << std::string("Error loading blockchain db: ") + e.what() + " -- shutting down now" << ENDL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// destructors called at exit:
|
|
||||||
//
|
|
||||||
// ensure db closed
|
// ensure db closed
|
||||||
// - transactions properly checked and handled
|
// - transactions properly checked and handled
|
||||||
// - disk sync if needed
|
// - disk sync if needed
|
||||||
//
|
//
|
||||||
// fake_core object's destructor is called when it goes out of scope. For an
|
core.deinit();
|
||||||
// LMDB fake_core, it calls Blockchain::deinit() on its object, which in turn
|
}
|
||||||
// calls delete on its BlockchainDB derived class' object, which closes its
|
catch (const DB_ERROR& e)
|
||||||
// files.
|
{
|
||||||
|
std::cout << std::string("Error loading blockchain db: ") + e.what() + " -- shutting down now" << ENDL;
|
||||||
|
core.deinit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
CATCH_ENTRY("Import error", 1);
|
CATCH_ENTRY("Import error", 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user