From 04453aada04983304031e05ad748d1a421f12e01 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 7 Feb 2014 00:16:50 +0000 Subject: [PATCH] Repot defaults. --- eth/main.cpp | 1 + libethereum/BlockChain.cpp | 11 +++------ libethereum/BlockChain.h | 17 -------------- libethereum/Client.cpp | 4 +++- libethereum/Defaults.cpp | 33 +++++++++++++++++++++++++++ libethereum/Defaults.h | 46 ++++++++++++++++++++++++++++++++++++++ libethereum/State.cpp | 4 +++- test/state.cpp | 1 + 8 files changed, 90 insertions(+), 27 deletions(-) create mode 100644 libethereum/Defaults.cpp create mode 100644 libethereum/Defaults.h diff --git a/eth/main.cpp b/eth/main.cpp index 9033e20e3..2d6c96a73 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -21,6 +21,7 @@ */ #include +#include "Defaults.h" #include "Client.h" #include "PeerNetwork.h" #include "BlockChain.h" diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index b92ad3915..b5ce18a6b 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -19,6 +19,8 @@ * @date 2014 */ +#include "BlockChain.h" + #include #include "Common.h" #include "RLP.h" @@ -26,8 +28,8 @@ #include "Dagger.h" #include "BlockInfo.h" #include "State.h" -#include "BlockChain.h" #include "FileSystem.h" +#include "Defaults.h" using namespace std; using namespace eth; @@ -48,13 +50,6 @@ std::ostream& operator<<(std::ostream& _out, BlockChain const& _bc) } } -Defaults* Defaults::s_this = nullptr; - -Defaults::Defaults() -{ - m_dbPath = getDataDir(); -} - BlockDetails::BlockDetails(RLP const& _r) { number = _r[0].toInt(); diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index d1197300e..61339dbb7 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -27,23 +27,6 @@ namespace ldb = leveldb; namespace eth { -struct Defaults -{ - friend class BlockChain; - friend class State; - -public: - Defaults(); - - static Defaults* get() { if (!s_this) s_this = new Defaults; return s_this; } - static void setDBPath(std::string const& _dbPath) { get()->m_dbPath = _dbPath; } - -private: - std::string m_dbPath; - - static Defaults* s_this; -}; - class RLP; class RLPStream; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 1dd3df4d2..774ba308e 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -19,8 +19,10 @@ * @date 2014 */ -#include "Common.h" #include "Client.h" + +#include "Common.h" +#include "Defaults.h" using namespace std; using namespace eth; diff --git a/libethereum/Defaults.cpp b/libethereum/Defaults.cpp new file mode 100644 index 000000000..6a09f5e6b --- /dev/null +++ b/libethereum/Defaults.cpp @@ -0,0 +1,33 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Foobar is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Foobar. If not, see . +*/ +/** @file Defaults.cpp + * @author Gav Wood + * @date 2014 + */ + +#include "Defaults.h" + +#include "FileSystem.h" +using namespace std; +using namespace eth; + +Defaults* Defaults::s_this = nullptr; + +Defaults::Defaults() +{ + m_dbPath = getDataDir(); +} diff --git a/libethereum/Defaults.h b/libethereum/Defaults.h new file mode 100644 index 000000000..b2b617899 --- /dev/null +++ b/libethereum/Defaults.h @@ -0,0 +1,46 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Foobar is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Foobar. If not, see . +*/ +/** @file Defaults.h + * @author Gav Wood + * @date 2014 + */ + +#pragma once + +#include "Common.h" + +namespace eth +{ + +struct Defaults +{ + friend class BlockChain; + friend class State; + +public: + Defaults(); + + static Defaults* get() { if (!s_this) s_this = new Defaults; return s_this; } + static void setDBPath(std::string const& _dbPath) { get()->m_dbPath = _dbPath; } + +private: + std::string m_dbPath; + + static Defaults* s_this; +}; + +} diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 1cba9c197..ceef91b24 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -19,6 +19,8 @@ * @date 2014 */ +#include "State.h" + #include #include #if WIN32 @@ -40,7 +42,7 @@ #include "Instruction.h" #include "Exceptions.h" #include "Dagger.h" -#include "State.h" +#include "Defaults.h" using namespace std; using namespace eth; diff --git a/test/state.cpp b/test/state.cpp index 2ba409c43..25663b851 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace std; using namespace eth;