diff options
author | Satoshi Nakamoto <satoshin@gmx.com> | 2010-07-26 17:40:05 +0000 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2010-07-26 17:40:05 +0000 |
commit | 40cd0369419323f8d7385950e20342e998c994e1 (patch) | |
tree | af4d40473a1073f108442aa8fe50a9b72462ece4 /main.h | |
parent | fe98cf8dc5066368b78e9ce208118c3532598dd2 (diff) | |
download | bitcoin-40cd0369419323f8d7385950e20342e998c994e1.tar.xz |
Gavin Andresen's JSON-RPC HTTP authentication,v0.3.3
faster initial block download
-- version 0.3.3
Diffstat (limited to 'main.h')
-rw-r--r-- | main.h | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -32,6 +32,7 @@ extern map<uint256, CBlockIndex*> mapBlockIndex; extern const uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock; extern int nBestHeight; +extern CBigNum bnBestChainWork; extern uint256 hashBestChain; extern CBlockIndex* pindexBest; extern unsigned int nTransactionsUpdated; @@ -78,6 +79,7 @@ string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtx void GenerateBitcoins(bool fGenerate); void ThreadBitcoinMiner(void* parg); void BitcoinMiner(); +bool IsInitialBlockDownload(); @@ -986,11 +988,14 @@ public: // 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; } @@ -1072,6 +1077,7 @@ public: unsigned int nFile; unsigned int nBlockPos; int nHeight; + CBigNum bnChainWork; // block header int nVersion; @@ -1089,6 +1095,7 @@ public: nFile = 0; nBlockPos = 0; nHeight = 0; + bnChainWork = 0; nVersion = 0; hashMerkleRoot = 0; @@ -1105,6 +1112,7 @@ public: nFile = nFileIn; nBlockPos = nBlockPosIn; nHeight = 0; + bnChainWork = 0; nVersion = block.nVersion; hashMerkleRoot = block.hashMerkleRoot; @@ -1118,6 +1126,11 @@ public: return *phashBlock; } + CBigNum GetBlockWork() const + { + return (CBigNum(1)<<256) / (CBigNum().SetCompact(nBits)+1); + } + bool IsInMainChain() const { return (pnext || this == pindexBest); |