Merge branch '0.4.x' into 0.5.0.x
authorLuke Dashjr <luke-jr+git@utopios.org>
Fri, 3 Feb 2012 01:17:41 +0000 (20:17 -0500)
committerLuke Dashjr <luke-jr+git@utopios.org>
Fri, 3 Feb 2012 01:17:41 +0000 (20:17 -0500)
Conflicts:
src/main.cpp

1  2 
src/db.cpp
src/init.cpp
src/key.h
src/main.cpp
src/main.h
src/net.cpp

diff --cc src/db.cpp
Simple merge
diff --cc src/init.cpp
Simple merge
diff --cc src/key.h
Simple merge
diff --cc src/main.cpp
@@@ -821,12 -834,16 +847,19 @@@ bool CTransaction::DisconnectInputs(CTx
  
  
  bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
-                                  CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee)
+                                  CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee,
+                                  bool& fInvalid)
  {
+     // FetchInputs can return false either because we just haven't seen some inputs
+     // (in which case the transaction should be stored as an orphan)
+     // or because the transaction is malformed (in which case the transaction should
+     // be dropped).  If tx is definitely invalid, fInvalid will be set to true.
+     fInvalid = false;
      // Take over previous transactions' spent pointers
 +    // fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain
 +    // fMiner is true when called from the internal bitcoin miner
 +    // ... both are false when called from CTransaction::AcceptToMemoryPool
      if (!IsCoinBase())
      {
          int64 nValueIn = 0;
              }
  
              if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size())
+             {
+                 // Revisit this if/when transaction replacement is implemented and allows
+                 // adding inputs:
+                 fInvalid = true;
 -                return error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str());
 +                return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()));
+             }
  
              // If prev is coinbase, check that it's matured
              if (txPrev.IsCoinBase())
@@@ -1311,8 -1328,8 +1350,8 @@@ bool CBlock::AcceptBlock(
      int nHeight = pindexPrev->nHeight+1;
  
      // Check proof of work
-     if (nBits != GetNextWorkRequired(pindexPrev))
+     if (nBits != GetNextWorkRequired(pindexPrev, this))
 -        return error("AcceptBlock() : incorrect proof of work");
 +        return DoS(100, error("AcceptBlock() : incorrect proof of work"));
  
      // Check timestamp against prev
      if (GetBlockTime() <= pindexPrev->GetMedianTimePast())
diff --cc src/main.h
Simple merge
diff --cc src/net.cpp
Simple merge