diff --git a/alethzero/Main.ui b/alethzero/Main.ui
index 54c3207cd..066e34610 100644
--- a/alethzero/Main.ui
+++ b/alethzero/Main.ui
@@ -150,6 +150,7 @@
+
@@ -1026,6 +1027,11 @@
Mining &Paranoia
+
+
+ &Kill Blockchain
+
+
diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index ac6b3a098..8fa676cf4 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -168,7 +168,6 @@ Main::Main(QWidget *parent) :
ui->setupUi(this);
g_logPost = [=](std::string const& s, char const* c) { simpleDebugOut(s, c); ui->log->addItem(QString::fromStdString(s)); };
m_client.reset(new Client("AlethZero"));
- m_client->setParanoia(false);
m_refresh = new QTimer(this);
connect(m_refresh, SIGNAL(timeout()), SLOT(refresh()));
@@ -881,6 +880,16 @@ void Main::on_data_textChanged()
updateFee();
}
+void Main::on_killBlockchain_triggered()
+{
+ writeSettings();
+ ui->mine->setChecked(false);
+ ui->net->setChecked(false);
+ m_client.reset();
+ m_client.reset(new Client("AlethZero", Address(), string(), true));
+ readSettings();
+}
+
bool Main::isCreation() const
{
return ui->destination->currentText().isEmpty() || ui->destination->currentText() == "(Create Contract)";
diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h
index 5e1ba23eb..9160831fd 100644
--- a/alethzero/MainWin.h
+++ b/alethzero/MainWin.h
@@ -76,6 +76,7 @@ private slots:
void on_debug_clicked();
void on_debugTimeline_valueChanged();
void on_jsInput_returnPressed();
+ void on_killBlockchain_triggered();
void refresh(bool _override = false);
void refreshNetwork();
diff --git a/libethcore/TrieDB.cpp b/libethcore/TrieDB.cpp
index 7160fe5b5..1fa9155f7 100644
--- a/libethcore/TrieDB.cpp
+++ b/libethcore/TrieDB.cpp
@@ -29,4 +29,10 @@ namespace eth
const h256 c_shaNull = sha3(rlp(""));
+Overlay::~Overlay()
+{
+ if (m_db.use_count() == 1 && m_db.get())
+ cnote << "Closing state DB";
+}
+
}
diff --git a/libethcore/TrieDB.h b/libethcore/TrieDB.h
index c2afb40d3..a662645ea 100644
--- a/libethcore/TrieDB.h
+++ b/libethcore/TrieDB.h
@@ -65,6 +65,7 @@ class Overlay: public BasicMap
{
public:
Overlay(ldb::DB* _db = nullptr): m_db(_db) {}
+ ~Overlay();
ldb::DB* db() const { return m_db.get(); }
void setDB(ldb::DB* _db, bool _clearOverlay = true) { m_db = std::shared_ptr(_db); if (_clearOverlay) m_over.clear(); }
diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp
index c3f400976..410ddd70b 100644
--- a/libethereum/BlockChain.cpp
+++ b/libethereum/BlockChain.cpp
@@ -102,11 +102,14 @@ BlockChain::BlockChain(std::string _path, bool _killExisting)
m_detailsDB->Get(m_readOptions, ldb::Slice("best"), &l);
m_lastBlockHash = l.empty() ? m_genesisHash : *(h256*)l.data();
- cout << "Opened blockchain db. Latest: " << m_lastBlockHash << endl;
+ cnote << "Opened blockchain DB. Latest: " << m_lastBlockHash;
}
BlockChain::~BlockChain()
{
+ cnote << "Closing blockchain DB";
+ delete m_detailsDB;
+ delete m_db;
}
template
diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp
index d56313fd3..6f9c7e202 100644
--- a/libethereum/Client.cpp
+++ b/libethereum/Client.cpp
@@ -50,11 +50,11 @@ void VersionChecker::setOk()
}
}
-Client::Client(std::string const& _clientVersion, Address _us, std::string const& _dbPath):
+Client::Client(std::string const& _clientVersion, Address _us, std::string const& _dbPath, bool _forceClean):
m_clientVersion(_clientVersion),
m_vc(_dbPath, PeerServer::protocolVersion()),
- m_bc(_dbPath, !m_vc.ok()),
- m_stateDB(State::openDB(_dbPath, !m_vc.ok())),
+ m_bc(_dbPath, !m_vc.ok() || _forceClean),
+ m_stateDB(State::openDB(_dbPath, !m_vc.ok() || _forceClean)),
m_preMine(_us, m_stateDB),
m_postMine(_us, m_stateDB),
m_workState(Active)
diff --git a/libethereum/Client.h b/libethereum/Client.h
index 372a8ddc2..e9cc845df 100644
--- a/libethereum/Client.h
+++ b/libethereum/Client.h
@@ -78,7 +78,7 @@ class Client
{
public:
/// Constructor.
- explicit Client(std::string const& _clientVersion, Address _us = Address(), std::string const& _dbPath = std::string());
+ explicit Client(std::string const& _clientVersion, Address _us = Address(), std::string const& _dbPath = std::string(), bool _forceClean = false);
/// Destructor.
~Client();
diff --git a/libethereum/State.cpp b/libethereum/State.cpp
index 4184b5b57..e2e127f8b 100644
--- a/libethereum/State.cpp
+++ b/libethereum/State.cpp
@@ -64,6 +64,7 @@ Overlay State::openDB(std::string _path, bool _killExisting)
o.create_if_missing = true;
ldb::DB* db = nullptr;
ldb::DB::Open(o, _path + "/state", &db);
+ cnote << "Opened state DB.";
return Overlay(db);
}