// Copyright (c) 2016 The Zcash developers
// Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#include "uint256.h"
+#include "consensus/params.h"
#include <atomic>
#include <mutex>
--value;
}
- int get() const {
+ uint64_t get() const {
return value.load();
}
};
class AtomicTimer {
-private:
+protected:
std::mutex mtx;
uint64_t threads;
int64_t start_time;
bool running();
- double rate(const AtomicCounter& count);
+ uint64_t threadCount();
+
+ double rate(const AtomicCounter &count);
+ double rate(const int64_t &count);
+};
+
+class PerfCounterTimer : public AtomicTimer {
+protected:
+ int64_t counter;
+ static const int64_t CLEAR_THRESHHOLD = 2;
+public:
+ PerfCounterTimer() : AtomicTimer() {}
+
+ /**
+ * Clears and initializes timer to enable restart of count on restart of mining.
+ * Only resets if thread count is 0.
+ */
+ void clear();
+
+ int64_t operator+=(int64_t operand);
+
+ double rate();
+ double rate(const AtomicCounter &count);
+ double rate(const int64_t &count);
};
extern AtomicCounter transactionsValidated;
extern AtomicCounter ehSolverRuns;
extern AtomicCounter solutionTargetChecks;
+extern PerfCounterTimer miningTimer;
void TrackMinedBlock(uint256 hash);
void MarkStartTime();
double GetLocalSolPS();
+int EstimateNetHeight(const Consensus::Params& params, int currentBlockHeight, int64_t currentBlockTime);
void TriggerRefresh();