Merge branch 'master' of https://github.com/bitcoin/bitcoin
authorWladimir J. van der Laan <laanwj@gmail.com>
Wed, 7 Sep 2011 16:57:11 +0000 (18:57 +0200)
committerWladimir J. van der Laan <laanwj@gmail.com>
Wed, 7 Sep 2011 16:57:11 +0000 (18:57 +0200)
Conflicts:
.gitignore

1  2 
.gitignore
README-original.md
src/main.cpp

diff --combined .gitignore
@@@ -3,12 -3,9 +3,18 @@@ src/bitcoi
  src/bitcoind
  .*.swp
  *.*~*
+ *.bak
+ *.rej
+ *.orig
+ *.o
+ *.patch
+ .bitcoin
 +#compilation and Qt preprocessor part
 +*.o
 +ui_*.h
 +*.qm
 +moc_*
 +Makefile
 +bitcoin-qt
 +#resources cpp
- qrc_*.cpp
++qrc_*.cpp
diff --combined README-original.md
@@@ -1,16 -1,30 +1,30 @@@
  Bitcoin integration/staging tree
  
  Development process
  ===================
  
- Developers work in their own trees, then submit pull requests when they think their feature or bug fix is ready.
+ Developers work in their own trees, then submit pull requests when
+ they think their feature or bug fix is ready.
+ If it is a simple/trivial/non-controversial change, then one of the
+ bitcoin development team members simply pulls it.
  
- If it is a simple/trivial/non-controversial change, then one of the bitcoin development team members simply pulls it.
+ If it is a more complicated or potentially controversial
+ change, then the patch submitter will be asked to start a
+ discussion (if they haven't already) on the mailing list:
+ http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development
  
- If it is a more complicated or potentially controversial change, then the patch submitter will be asked to start a discussion (if they haven't already) on the development forums:  http://www.bitcoin.org/smf/index.php?board=6.0
- The patch will be accepted if there is broad consensus that it is a good thing.  Developers should expect to rework and resubmit patches if they don't match the project's coding conventions (see coding.txt) or are controversial.
+ The patch will be accepted if there is broad consensus that it is a
+ good thing.  Developers should expect to rework and resubmit patches
+ if they don't match the project's coding conventions (see coding.txt)
+ or are controversial.
  
- The master branch is regularly built and tested (by who? need people willing to be quality assurance testers), and periodically pushed to the subversion repo to become the official, stable, released bitcoin.
+ The master branch is regularly built and tested, but is not guaranteed
+ to be completely stable. Tags are regularly created to indicate new
+ official, stable release versions of Bitcoin. If you would like to
+ help test the Bitcoin core, please contact QA@Bitcoin.org.
  
+ Feature branches are created when there are major new features being
+ worked on by several people.
  
- Feature branches are created when there are major new features being worked on by several people.
diff --combined src/main.cpp
@@@ -31,7 -31,6 +31,7 @@@ map<uint256, CBlockIndex*> mapBlockInde
  uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
  static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
  const int nTotalBlocksEstimate = 140700; // Conservative estimate of total nr of blocks on main chain
 +int nMaxBlocksOfOtherNodes = 0; // Maximum amount of blocks that other nodes claim to have
  const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download"
  CBlockIndex* pindexGenesisBlock = NULL;
  int nBestHeight = -1;
@@@ -727,12 -726,6 +727,12 @@@ int GetTotalBlocksEstimate(
      }
  }
  
 +// Return maximum amount of blocks that other nodes claim to have
 +int GetMaxBlocksOfOtherNodes()
 +{
 +    return nMaxBlocksOfOtherNodes;
 +}
 +
  bool IsInitialBlockDownload()
  {
      if (pindexBest == NULL || nBestHeight < (GetTotalBlocksEstimate()-nInitialBlockThreshold))
@@@ -820,7 -813,7 +820,7 @@@ bool CTransaction::ConnectInputs(CTxDB
              // Read txindex
              CTxIndex txindex;
              bool fFound = true;
-             if (fMiner && mapTestPool.count(prevout.hash))
+             if ((fBlock || fMiner) && mapTestPool.count(prevout.hash))
              {
                  // Get txindex from current proposed changes
                  txindex = mapTestPool[prevout.hash];
              txindex.vSpent[prevout.n] = posThisTx;
  
              // Write back
-             if (fBlock)
-             {
-                 if (!txdb.UpdateTxIndex(prevout.hash, txindex))
-                     return error("ConnectInputs() : UpdateTxIndex failed");
-             }
-             else if (fMiner)
+             if (fBlock || fMiner)
              {
                  mapTestPool[prevout.hash] = txindex;
              }
  
      if (fBlock)
      {
-         // Add transaction to disk index
-         if (!txdb.AddTxIndex(*this, posThisTx, pindexBlock->nHeight))
-             return error("ConnectInputs() : AddTxPos failed");
+         // Add transaction to changes
+         mapTestPool[GetHash()] = CTxIndex(posThisTx, vout.size());
      }
      else if (fMiner)
      {
@@@ -998,16 -985,22 +992,22 @@@ bool CBlock::ConnectBlock(CTxDB& txdb, 
      //// issue here: it doesn't know the version
      unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size());
  
-     map<uint256, CTxIndex> mapUnused;
+     map<uint256, CTxIndex> mapQueuedChanges;
      int64 nFees = 0;
      BOOST_FOREACH(CTransaction& tx, vtx)
      {
          CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
          nTxPos += ::GetSerializeSize(tx, SER_DISK);
  
-         if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex, nFees, true, false))
+         if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false))
              return false;
      }
+     // Write queued txindex changes
+     for (map<uint256, CTxIndex>::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi)
+     {
+         if (!txdb.UpdateTxIndex((*mi).first, (*mi).second))
+             return error("ConnectBlock() : UpdateTxIndex failed");
+     }
  
      if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees))
          return false;
@@@ -1846,10 -1839,6 +1846,10 @@@ bool static ProcessMessage(CNode* pfrom
          pfrom->fSuccessfullyConnected = true;
  
          printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
 +        if(pfrom->nStartingHeight > nMaxBlocksOfOtherNodes)
 +        {
 +            nMaxBlocksOfOtherNodes = pfrom->nStartingHeight;
 +        }
      }