Browse Source

Merge branch 'develop' into reqpeer

cl-refactor
subtly 10 years ago
parent
commit
b025980db8
  1. 1
      libethcore/Exceptions.h
  2. 17
      libethereum/BlockChain.cpp
  3. 13
      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>;
struct DatabaseAlreadyOpen: virtual dev::Exception {};
struct NotEnoughAvailableSpace: virtual dev::Exception {};
struct NotEnoughCash: virtual dev::Exception {};
struct GasPriceTooLow: virtual dev::Exception {};
struct BlockGasLimitReached: virtual dev::Exception {};

17
libethereum/BlockChain.cpp

@ -131,10 +131,19 @@ void BlockChain::open(std::string _path, bool _killExisting)
o.create_if_missing = true;
ldb::DB::Open(o, _path + "/blocks", &m_blocksDB);
ldb::DB::Open(o, _path + "/details", &m_extrasDB);
if (!m_blocksDB)
BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen());
if (!m_extrasDB)
BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen());
if (!m_blocksDB || !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());
}
}
if (!details(m_genesisHash))
{

13
libethereum/State.cpp

@ -60,7 +60,18 @@ OverlayDB State::openDB(std::string _path, bool _killExisting)
ldb::DB* db = nullptr;
ldb::DB::Open(o, _path + "/state", &db);
if (!db)
BOOST_THROW_EXCEPTION(DatabaseAlreadyOpen());
{
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());
}
}
cnote << "Opened state DB.";
return OverlayDB(db);

Loading…
Cancel
Save