From 22c4272bf4ea04689fc0ea08e637caa46ba12c98 Mon Sep 17 00:00:00 2001 From: jtimon Date: Wed, 22 Oct 2014 01:31:01 +0200 Subject: [PATCH] MOVEONLY: Move void UpdateTime() from pow.o to miner.o (plus fix include main.h -> chain.h) --- src/miner.cpp | 10 ++++++++++ src/miner.h | 2 ++ src/pow.cpp | 12 +----------- src/pow.h | 2 -- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 0235de3ab..d3bbc6235 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -12,6 +12,7 @@ #include "main.h" #include "net.h" #include "pow.h" +#include "timedata.h" #include "util.h" #include "utilmoneystr.h" #ifdef ENABLE_WALLET @@ -78,6 +79,15 @@ public: } }; +void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev) +{ + pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); + + // Updating time can change work required on testnet: + if (Params().AllowMinDifficultyBlocks()) + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock); +} + CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { // Create new block diff --git a/src/miner.h b/src/miner.h index 1fa499dc5..aede0e6d4 100644 --- a/src/miner.h +++ b/src/miner.h @@ -9,6 +9,7 @@ #include class CBlock; +class CBlockHeader; class CBlockIndex; class CReserveKey; class CScript; @@ -25,6 +26,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey); void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce); /** Check mined block */ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); +void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev); extern double dHashesPerSec; extern int64_t nHPSTimerStart; diff --git a/src/pow.cpp b/src/pow.cpp index af7fc488e..483122a76 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -5,10 +5,9 @@ #include "pow.h" +#include "chain.h" #include "chainparams.h" #include "core/block.h" -#include "main.h" -#include "timedata.h" #include "uint256.h" #include "util.h" @@ -98,15 +97,6 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits) return true; } -void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev) -{ - pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - - // Updating time can change work required on testnet: - if (Params().AllowMinDifficultyBlocks()) - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock); -} - uint256 GetProofIncrement(unsigned int nBits) { uint256 bnTarget; diff --git a/src/pow.h b/src/pow.h index 233d1f379..9ee6ce44d 100644 --- a/src/pow.h +++ b/src/pow.h @@ -17,8 +17,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */ bool CheckProofOfWork(uint256 hash, unsigned int nBits); -void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev); - uint256 GetProofIncrement(unsigned int nBits); #endif // BITCOIN_POW_H