Skip to content

Commit 2b7377f

Browse files
add ProgOpt::Reload()
1 parent 03dd0b9 commit 2b7377f

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

ethminer/FarmClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class FarmClient : public jsonrpc::Client
196196
t.nonce = m_txNonce;
197197
t.receiveAddress = toAddress(m_tokenContract);
198198
t.gas = u256(200000);
199-
ProgOpt::Load("");
199+
ProgOpt::Reload();
200200
m_startGas = atoi(ProgOpt::Get("0xBitcoin", "GasPrice").c_str());
201201
m_maxGas = atoi(ProgOpt::Get("0xBitcoin", "MaxGasPrice").c_str());
202202
t.gasPrice = RecommendedGasPrice(_challenge);

ethminer/ProgOpt.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ along with mvis-ethereum. If not, see <http://www.gnu.org/licenses/>.
1919
#include <ethminer/ProgOpt.h>
2020
#include <ethminer/ini_parser_ex.hpp>
2121
#include <string>
22-
#include <boost/filesystem.hpp>
2322
#include <boost/lexical_cast.hpp>
2423
#include <ethminer/Misc.h>
2524
#include <ethminer/MultiLog.h>
@@ -31,6 +30,7 @@ namespace fs = boost::filesystem;
3130
pt::iptree *ProgOpt::m_tree;
3231
bool ProgOpt::m_updating = false;
3332
ProgOpt::defaults_t *ProgOpt::m_defaults;
33+
boost::filesystem::path ProgOpt::m_path;
3434

3535

3636
bool ProgOpt::Load(std::string _config)
@@ -47,20 +47,19 @@ bool ProgOpt::Load(std::string _config)
4747
return false;
4848
}
4949

50-
fs::path path;
5150
if (_config != "")
52-
path = _config;
51+
m_path = _config;
5352
else
5453
{
5554
// try current folder first
56-
path = getExecFolder();
57-
path = path / "tokenminer.ini";
58-
if (!fs::exists(path))
55+
m_path = getExecFolder();
56+
m_path = m_path / "tokenminer.ini";
57+
if (!fs::exists(m_path))
5958
{
6059
// check %LocalAppData
61-
path = getAppDataFolder();
62-
path = path / "tokenminer.ini";
63-
if (!fs::exists(path))
60+
m_path = getAppDataFolder();
61+
m_path = m_path / "tokenminer.ini";
62+
if (!fs::exists(m_path))
6463
{
6564
LogB << "Error! Tokenminer.ini settings file not found.";
6665
return false;
@@ -69,7 +68,7 @@ bool ProgOpt::Load(std::string _config)
6968
}
7069
try
7170
{
72-
pt::read_ini_ex(path.generic_string(), *m_tree);
71+
pt::read_ini_ex(m_path.generic_string(), *m_tree);
7372

7473
// set up sensible defaults for various settings. note that emplace does
7574
// not overwrite existing values.
@@ -90,11 +89,14 @@ bool ProgOpt::Load(std::string _config)
9089
return true;
9190
}
9291

92+
void ProgOpt::Reload()
93+
{
94+
Load(m_path.generic_string());
95+
}
96+
9397
void ProgOpt::SaveToDisk()
9498
{
95-
fs::path path = getAppDataFolder();
96-
path = path / "tokenminer.ini";
97-
pt::write_ini(path.string(), *m_tree);
99+
pt::write_ini(m_path.string(), *m_tree);
98100
}
99101

100102
std::string ProgOpt::Get(std::string _section, std::string _key, std::string _default)

ethminer/ProgOpt.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ along with mvis-ethereum. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

2020
#include <boost/property_tree/ptree.hpp>
21+
#include <boost/filesystem.hpp>
2122
#include <unordered_map>
2223

2324
class ProgOpt
@@ -26,6 +27,7 @@ class ProgOpt
2627
public:
2728

2829
static bool Load(std::string _config);
30+
static void Reload();
2931
static void SaveToDisk();
3032
static std::string Get(std::string _section, std::string _key, std::string _default);
3133
static std::string Get(std::string _section, std::string _key);
@@ -41,5 +43,5 @@ class ProgOpt
4143
static boost::property_tree::iptree *m_tree;
4244
static defaults_t *m_defaults;
4345
static bool m_updating;
44-
46+
static boost::filesystem::path m_path;
4547
};

0 commit comments

Comments
 (0)