Browse Source

Merge branch 'develop' into reqpeer

cl-refactor
subtly 10 years ago
parent
commit
b025980db8
  1. 1
      libethcore/Exceptions.h
  2. 15
      libethereum/BlockChain.cpp
  3. 11
      libethereum/State.cpp

1
libethcore/Exceptions.h

@ -38,6 +38,7 @@ using errinfo_difficulty = boost::error_info<struct tag_difficulty, u256>;
using BadFieldError = boost::tuple<errinfo_field, errinfo_data>; using BadFieldError = boost::tuple<errinfo_field, errinfo_data>;
struct DatabaseAlreadyOpen: virtual dev::Exception {}; struct DatabaseAlreadyOpen: virtual dev::Exception {};
struct NotEnoughAvailableSpace: virtual dev::Exception {};
struct NotEnoughCash: virtual dev::Exception {}; struct NotEnoughCash: virtual dev::Exception {};
struct GasPriceTooLow: virtual dev::Exception {}; struct GasPriceTooLow: virtual dev::Exception {};
struct BlockGasLimitReached: virtual dev::Exception {}; struct BlockGasLimitReached: virtual dev::Exception {};

15
libethereum/BlockChain.cpp

@ -131,10 +131,19 @@ void BlockChain::open(std::string _path, bool _killExisting)
o.create_if_missing = true; o.create_if_missing = true;
ldb::DB::Open(o, _path + "/blocks", &m_blocksDB); ldb::DB::Open(o, _path + "/blocks", &m_blocksDB);
ldb::DB::Open(o, _path + "/details", &m_extrasDB); ldb::DB::Open(o, _path + "/details", &m_extrasDB);
if (!m_blocksDB) if (!m_blocksDB || !m_extrasDB)
BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); {
if (!m_extrasDB) if (boost::filesystem::space(_path + "/blocks").available < 1024)
{
cwarn << "Not enough available space found on hard drive. Please free some up and then re-run. Bailing.";
BOOST_THROW_EXCEPTION(NotEnoughAvailableSpace());
}
else
{
cwarn << "Database already open. You appear to have another instance of ethereum running. Bailing.";
BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen());
}
}
if (!details(m_genesisHash)) if (!details(m_genesisHash))
{ {

11
libethereum/State.cpp

@ -60,7 +60,18 @@ OverlayDB State::openDB(std::string _path, bool _killExisting)
ldb::DB* db = nullptr; ldb::DB* db = nullptr;
ldb::DB::Open(o, _path + "/state", &db); ldb::DB::Open(o, _path + "/state", &db);
if (!db) if (!db)
{
if (boost::filesystem::space(_path + "/state").available < 1024)
{
cwarn << "Not enough available space found on hard drive. Please free some up and then re-run. Bailing.";
BOOST_THROW_EXCEPTION(NotEnoughAvailableSpace());
}
else
{
cwarn << "Database already open. You appear to have another instance of ethereum running. Bailing.";
BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen()); BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen());
}
}
cnote << "Opened state DB."; cnote << "Opened state DB.";
return OverlayDB(db); return OverlayDB(db);

Loading…
Cancel
Save