extern const uint256 hashGenesisBlock;
extern CBlockIndex* pindexGenesisBlock;
extern int nBestHeight;
+extern CBigNum bnBestChainWork;
extern uint256 hashBestChain;
extern CBlockIndex* pindexBest;
extern unsigned int nTransactionsUpdated;
void GenerateBitcoins(bool fGenerate);
void ThreadBitcoinMiner(void* parg);
void BitcoinMiner();
+bool IsInitialBlockDownload();
// Flush stdio buffers and commit to disk before returning
fflush(fileout);
+ if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0)
+ {
#ifdef __WXMSW__
- _commit(_fileno(fileout));
+ _commit(_fileno(fileout));
#else
- fsync(fileno(fileout));
+ fsync(fileno(fileout));
#endif
+ }
return true;
}
unsigned int nFile;
unsigned int nBlockPos;
int nHeight;
+ CBigNum bnChainWork;
// block header
int nVersion;
nFile = 0;
nBlockPos = 0;
nHeight = 0;
+ bnChainWork = 0;
nVersion = 0;
hashMerkleRoot = 0;
nFile = nFileIn;
nBlockPos = nBlockPosIn;
nHeight = 0;
+ bnChainWork = 0;
nVersion = block.nVersion;
hashMerkleRoot = block.hashMerkleRoot;
return *phashBlock;
}
+ CBigNum GetBlockWork() const
+ {
+ return (CBigNum(1)<<256) / (CBigNum().SetCompact(nBits)+1);
+ }
+
bool IsInMainChain() const
{
return (pnext || this == pindexBest);