#include <boost/thread.hpp>
#include <boost/thread/synchronized_value.hpp>
#include <string>
-#ifdef WIN32
+#ifdef _WIN32
#include <io.h>
+#include <windows.h>
#else
#include <sys/ioctl.h>
#endif
#include <unistd.h>
+extern uint64_t ASSETCHAINS_TIMELOCKGTE;
+extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH;
+int64_t komodo_block_unlocktime(uint32_t nHeight);
+
void AtomicTimer::start()
{
std::unique_lock<std::mutex> lock(mtx);
return duration > 0 ? (double)count.get() / duration : 0;
}
-static CCriticalSection cs_metrics;
-
-static boost::synchronized_value<int64_t> nNodeStartTime;
-static boost::synchronized_value<int64_t> nNextRefresh;
+boost::synchronized_value<int64_t> nNodeStartTime;
+boost::synchronized_value<int64_t> nNextRefresh;
AtomicCounter transactionsValidated;
AtomicCounter ehSolverRuns;
AtomicCounter solutionTargetChecks;
static AtomicCounter minedBlocks;
-AtomicTimer miningTimer;
+PerfCounterTimer miningTimer;
+CCriticalSection cs_metrics;
+
+double AtomicTimer::rate(const int64_t &count)
+{
+ std::unique_lock<std::mutex> lock(mtx);
+ LOCK(cs_metrics);
+ int64_t duration = total_time;
+ if (threads > 0) {
+ // Timer is running, so get the latest count
+ duration += GetTime() - start_time;
+ }
+ return duration > 0 ? (double)count / duration : 0;
+}
+
+double PerfCounterTimer::rate()
+{
+ return AtomicTimer::rate(counter);
+}
+
+double PerfCounterTimer::rate(const AtomicCounter &count)
+{
+ return AtomicTimer::rate(count);
+}
+
+double PerfCounterTimer::rate(const int64_t &count)
+{
+ return AtomicTimer::rate(count);
+}
+
+void PerfCounterTimer::clear()
+{
+ std::unique_lock<std::mutex> lock(mtx);
+ if (!threads)
+ {
+ counter = 0;
+ start_time = GetTime();
+ total_time = 0;
+ }
+}
+
+int64_t PerfCounterTimer::operator+=(int64_t operand)
+{
+ std::unique_lock<std::mutex> lock(mtx);
+ return counter += operand;
+}
static boost::synchronized_value<std::list<uint256>> trackedBlocks;
double GetLocalSolPS()
{
- return miningTimer.rate(solutionTargetChecks);
+ if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
+ {
+ return miningTimer.rate();
+ }
+ else
+ return miningTimer.rate(solutionTargetChecks);
}
int EstimateNetHeight(const Consensus::Params& params, int currentHeadersHeight, int64_t currentHeadersTime)
{
LOCK2(cs_main, cs_vNodes);
height = chainActive.Height();
- currentHeadersHeight = pindexBestHeader ? pindexBestHeader->nHeight: -1;
+ currentHeadersHeight = pindexBestHeader ? pindexBestHeader->GetHeight(): -1;
currentHeadersTime = pindexBestHeader ? pindexBestHeader->nTime : 0;
connections = vNodes.size();
netsolps = GetNetworkHashPS(120, -1);
auto hash = *it;
if (mapBlockIndex.count(hash) > 0 &&
chainActive.Contains(mapBlockIndex[hash])) {
- int height = mapBlockIndex[hash]->nHeight;
+ int height = mapBlockIndex[hash]->GetHeight();
CAmount subsidy = GetBlockSubsidy(height, consensusParams);
if ((height > 0) && (height <= consensusParams.GetLastFoundersRewardBlockHeight(height))) {
subsidy -= subsidy/5;
}
- if (std::max(0, COINBASE_MATURITY - (tipHeight - height)) > 0) {
+
+ if ((std::max(0, COINBASE_MATURITY - (tipHeight - height)) > 0) ||
+ (tipHeight < komodo_block_unlocktime(height) && subsidy >= ASSETCHAINS_TIMELOCKGTE)) {
immature += subsidy;
} else {
mature += subsidy;
// Get current window size
if (isTTY) {
-#ifdef WIN32
+#ifdef _WIN32
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) != 0) {
cols = csbi.srWindow.Right - csbi.srWindow.Left + 1;