|
@ -185,6 +185,8 @@ void BlockChain::close() |
|
|
|
|
|
|
|
|
void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned, unsigned)> const& _progress) |
|
|
void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned, unsigned)> const& _progress) |
|
|
{ |
|
|
{ |
|
|
|
|
|
std::string path = _path.empty() ? Defaults::get()->m_dbPath : _path; |
|
|
|
|
|
|
|
|
#if ETH_PROFILING_GPERF |
|
|
#if ETH_PROFILING_GPERF |
|
|
ProfilerStart("BlockChain_rebuild.log"); |
|
|
ProfilerStart("BlockChain_rebuild.log"); |
|
|
#endif |
|
|
#endif |
|
@ -195,16 +197,16 @@ void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned, |
|
|
// Keep extras DB around, but under a temp name
|
|
|
// Keep extras DB around, but under a temp name
|
|
|
delete m_extrasDB; |
|
|
delete m_extrasDB; |
|
|
m_extrasDB = nullptr; |
|
|
m_extrasDB = nullptr; |
|
|
IGNORE_EXCEPTIONS(boost::filesystem::remove_all(_path + "/details.old")); |
|
|
IGNORE_EXCEPTIONS(boost::filesystem::remove_all(path + "/details.old")); |
|
|
boost::filesystem::rename(_path + "/details", _path + "/details.old"); |
|
|
boost::filesystem::rename(path + "/details", path + "/details.old"); |
|
|
ldb::DB* oldExtrasDB; |
|
|
ldb::DB* oldExtrasDB; |
|
|
ldb::Options o; |
|
|
ldb::Options o; |
|
|
o.create_if_missing = true; |
|
|
o.create_if_missing = true; |
|
|
ldb::DB::Open(o, _path + "/details.old", &oldExtrasDB); |
|
|
ldb::DB::Open(o, path + "/details.old", &oldExtrasDB); |
|
|
ldb::DB::Open(o, _path + "/details", &m_extrasDB); |
|
|
ldb::DB::Open(o, path + "/details", &m_extrasDB); |
|
|
|
|
|
|
|
|
// Open a fresh state DB
|
|
|
// Open a fresh state DB
|
|
|
State s(State::openDB(_path, WithExisting::Kill), BaseState::CanonGenesis); |
|
|
State s(State::openDB(path, WithExisting::Kill), BaseState::CanonGenesis); |
|
|
|
|
|
|
|
|
// Clear all memos ready for replay.
|
|
|
// Clear all memos ready for replay.
|
|
|
m_details.clear(); |
|
|
m_details.clear(); |
|
@ -255,7 +257,7 @@ void BlockChain::rebuild(std::string const& _path, std::function<void(unsigned, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
delete oldExtrasDB; |
|
|
delete oldExtrasDB; |
|
|
boost::filesystem::remove_all(_path + "/details.old"); |
|
|
boost::filesystem::remove_all(path + "/details.old"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template <class T, class V> |
|
|
template <class T, class V> |
|
|