]> Git Repo - VerusCoin.git/blobdiff - src/metrics.h
Fix stakeguard validation
[VerusCoin.git] / src / metrics.h
index ff1138b993d8440a01008c2dd22141254c5d2244..ea9358e55cb909ddb04d359e2f1a1011ed59c293 100644 (file)
@@ -1,8 +1,9 @@
 // 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>
@@ -21,13 +22,13 @@ struct AtomicCounter {
         --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;
@@ -49,17 +50,42 @@ public:
 
     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();
 
This page took 0.027417 seconds and 4 git commands to generate.