Skip to content

Commit fe00784

Browse files
committed
fix progress monitor in native mining
1 parent 98a53be commit fe00784

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ To install or update LODA, please follow the [installation instructions](https:/
55
### Bugfixes
66

77
* Fix handling of protected programs
8+
* Fix progress monitor for native mining (non-BOINC)
89

910
### Enhancements
1011

src/commands.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ void Commands::profile(const std::string& path) {
203203

204204
void Commands::mine() {
205205
initLog(false);
206-
Miner miner(settings);
206+
std::unique_ptr<ProgressMonitor> progress_monitor;
207+
if (settings.num_mine_hours > 0) {
208+
const int64_t target_seconds = settings.num_mine_hours * 3600;
209+
progress_monitor.reset(new ProgressMonitor(target_seconds, "", "", 0));
210+
}
211+
Miner miner(settings, Miner::DEFAULT_LOG_INTERVAL, progress_monitor.get());
207212
miner.mine();
208213
}
209214

src/include/miner.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class Miner {
2525
std::vector<Matcher::Config> matchers;
2626
};
2727

28-
Miner(const Settings &settings,
29-
int64_t log_interval = 120, // 2 minutes (magic number)
28+
static constexpr int64_t DEFAULT_LOG_INTERVAL = 120; // 2 minutes
29+
30+
Miner(const Settings &settings, int64_t log_interval = DEFAULT_LOG_INTERVAL,
3031
ProgressMonitor *progress_monitor = nullptr);
3132

3233
void mine();

src/util.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,12 @@ double ProgressMonitor::getProgress() {
453453
}
454454

455455
void ProgressMonitor::writeProgress() {
456-
if (progress_file.empty() || checkpoint_file.empty()) {
457-
Log::get().error("Error writing progress: missing file names", false);
458-
return;
459-
}
460-
{
456+
if (!progress_file.empty()) {
461457
std::ofstream progress_out(progress_file);
462458
progress_out.precision(3);
463459
progress_out << std::fixed << getProgress() << std::endl;
464460
}
465-
{
461+
if (!checkpoint_file.empty()) {
466462
std::ofstream checkpoint_out(checkpoint_file);
467463
checkpoint_out << encode(getElapsedSeconds()) << std::endl;
468464
}

0 commit comments

Comments
 (0)