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
This commit is contained in:
s_nakamoto
2010-07-25 16:45:21 +00:00
parent e8bff10f07
commit 3b7cd5d89a
18 changed files with 405 additions and 137 deletions

17
main.h
View File

@@ -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);