MOVEONLY: Move void UpdateTime() from pow.o to miner.o (plus fix include main.h -> chain.h)

pull/196/head
jtimon 10 years ago
parent 723c752636
commit 22c4272bf4

@ -12,6 +12,7 @@
#include "main.h" #include "main.h"
#include "net.h" #include "net.h"
#include "pow.h" #include "pow.h"
#include "timedata.h"
#include "util.h" #include "util.h"
#include "utilmoneystr.h" #include "utilmoneystr.h"
#ifdef ENABLE_WALLET #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) CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{ {
// Create new block // Create new block

@ -9,6 +9,7 @@
#include <stdint.h> #include <stdint.h>
class CBlock; class CBlock;
class CBlockHeader;
class CBlockIndex; class CBlockIndex;
class CReserveKey; class CReserveKey;
class CScript; class CScript;
@ -25,6 +26,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce); void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
/** Check mined block */ /** Check mined block */
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev);
extern double dHashesPerSec; extern double dHashesPerSec;
extern int64_t nHPSTimerStart; extern int64_t nHPSTimerStart;

@ -5,10 +5,9 @@
#include "pow.h" #include "pow.h"
#include "chain.h"
#include "chainparams.h" #include "chainparams.h"
#include "core/block.h" #include "core/block.h"
#include "main.h"
#include "timedata.h"
#include "uint256.h" #include "uint256.h"
#include "util.h" #include "util.h"
@ -98,15 +97,6 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
return true; 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 GetProofIncrement(unsigned int nBits)
{ {
uint256 bnTarget; uint256 bnTarget;

@ -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 */ /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
bool CheckProofOfWork(uint256 hash, unsigned int nBits); bool CheckProofOfWork(uint256 hash, unsigned int nBits);
void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev);
uint256 GetProofIncrement(unsigned int nBits); uint256 GetProofIncrement(unsigned int nBits);
#endif // BITCOIN_POW_H #endif // BITCOIN_POW_H

Loading…
Cancel
Save