Skip to content

Commit

Permalink
Added configurable get mining info interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Creepsky committed Jul 20, 2017
1 parent 4668f9f commit 3c52b2c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/mining/Miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ void Burst::Miner::run()

wallet_ = MinerConfig::getConfig().getWalletUrl();

const auto sleepTime = std::chrono::seconds(3);
#ifdef RUN_BENCHMARK
size_t benchmarkLoop = 0;
#endif
Expand Down Expand Up @@ -140,7 +139,7 @@ void Burst::Miner::run()
++benchmarkLoop;
#endif

std::this_thread::sleep_for(sleepTime);
std::this_thread::sleep_for(std::chrono::seconds(MinerConfig::getConfig().getMiningInfoInterval()));
}

running_ = false;
Expand Down
17 changes: 16 additions & 1 deletion src/mining/MinerConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ void Burst::MinerConfig::printConsole() const
log_system(MinerLogger::config, "Log path : %s", MinerConfig::getConfig().getPathLogfile().toString());

printConsolePlots();

log_system(MinerLogger::config, "Get mining info interval : %z", MinerConfig::getConfig().getMiningInfoInterval());
}

void Burst::MinerConfig::printConsolePlots() const
Expand Down Expand Up @@ -110,7 +112,7 @@ void Burst::MinerConfig::printUrl(const Url& url, const std::string& url_name)
void Burst::MinerConfig::printBufferSize() const
{
Poco::Mutex::ScopedLock lock(mutex_);
log_system(MinerLogger::config, "Buffer Size : %z MB", maxBufferSizeMB_);
log_system(MinerLogger::config, "Buffer Size : %z MB%s", maxBufferSizeMB_, maxBufferSizeMB_ == 0 ? " (unlimited)" : "");
}

template <typename T>
Expand Down Expand Up @@ -306,6 +308,7 @@ bool Burst::MinerConfig::readConfigFile(const std::string& configPath)

// use insecure plotfiles
useInsecurePlotfiles_ = getOrAdd(miningObj, "useInsecurePlotfiles", false);
getMiningInfoInterval_ = getOrAdd(miningObj, "getMiningInfoInterval", 3);

// urls
{
Expand Down Expand Up @@ -1171,6 +1174,12 @@ void Burst::MinerConfig::setLogDir(const std::string& log_dir)
log_system(MinerLogger::config, "Changed logfile path to\n\t%s", logDirAndFile);
}

void Burst::MinerConfig::setGetMiningInfoInterval(size_t interval)
{
Poco::Mutex::ScopedLock lock(mutex_);
getMiningInfoInterval_ = interval;
}

bool Burst::MinerConfig::addPlotDir(const std::string& dir)
{
return addPlotDir(std::make_shared<PlotDir>(dir, PlotDir::Type::Sequential));
Expand Down Expand Up @@ -1215,6 +1224,12 @@ bool Burst::MinerConfig::isLogfileUsed() const
return logfile_;
}

size_t Burst::MinerConfig::getMiningInfoInterval() const
{
Poco::Mutex::ScopedLock lock(mutex_);
return getMiningInfoInterval_;
}

void Burst::MinerConfig::useLogfile(bool use)
{
Poco::Mutex::ScopedLock lock(mutex_);
Expand Down
3 changes: 3 additions & 0 deletions src/mining/MinerConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace Burst
const std::string& getPassphrase() const;
bool useInsecurePlotfiles() const;
bool isLogfileUsed() const;
size_t getMiningInfoInterval() const;

/**
* \brief Returns the maximal amount of simultane plot reader.
Expand All @@ -171,6 +172,7 @@ namespace Burst
void setMininigIntensity(unsigned intensity);
void setMaxPlotReaders(unsigned max_reader);
void setLogDir(const std::string& log_dir);
void setGetMiningInfoInterval(size_t interval);

/**
* \brief Instructs the miner wether he should use a logfile.
Expand Down Expand Up @@ -229,6 +231,7 @@ namespace Burst
Passphrase passphrase_;
bool useInsecurePlotfiles_ = false;
bool logfile_ = true;
size_t getMiningInfoInterval_;
mutable Poco::Mutex mutex_;
};
}

0 comments on commit 3c52b2c

Please sign in to comment.