aboutsummaryrefslogtreecommitdiff
path: root/main.h
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-07-25 16:45:21 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-07-25 16:45:21 +0000
commit3b7cd5d89a226426df9c723d1f9ddfe08b7d1def (patch)
treecb956c8dd87690dcd9e5d554286d39edbb199c32 /main.h
parente8bff10f07b80d820545661cee9337d8664a64cb (diff)
downloadbitcoin-3b7cd5d89a226426df9c723d1f9ddfe08b7d1def.tar.xz
Gavin Andresen's JSON-RPC HTTP authentication,
faster initial block download -- version 0.3.3 git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@109 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'main.h')
-rw-r--r--main.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/main.h b/main.h
index 3c10e490ef..c9b2407176 100644
--- a/main.h
+++ b/main.h
@@ -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);