@@ -538,7 +538,7 @@ bool CTransaction::AcceptTransaction(CTxDB& txdb, bool fCheckInputs, bool* pfMis
538538 // Check against previous transactions
539539 map<uint256, CTxIndex> mapUnused;
540540 int64 nFees = 0 ;
541- if (fCheckInputs && !ConnectInputs (txdb, mapUnused, CDiskTxPos (1 ,1 ,1 ), 0 , nFees, false , false ))
541+ if (fCheckInputs && !ConnectInputs (txdb, mapUnused, CDiskTxPos (1 ,1 ,1 ), pindexBest , nFees, false , false ))
542542 {
543543 if (pfMissingInputs)
544544 *pfMissingInputs = true ;
@@ -744,7 +744,7 @@ void ResendWalletTransactions()
744744 if (GetTime () < nNextTime)
745745 return ;
746746 bool fFirst = (nNextTime == 0 );
747- nNextTime = GetTime () + GetRand (120 * 60 );
747+ nNextTime = GetTime () + GetRand (30 * 60 );
748748 if (fFirst )
749749 return ;
750750
@@ -760,7 +760,7 @@ void ResendWalletTransactions()
760760 CWalletTx& wtx = item.second ;
761761 // Don't rebroadcast until it's had plenty of time that
762762 // it should have gotten in already by now.
763- if (nTimeBestReceived - wtx.nTimeReceived > 60 * 60 )
763+ if (nTimeBestReceived - (int64) wtx.nTimeReceived > 5 * 60 )
764764 mapSorted.insert (make_pair (wtx.nTimeReceived , &wtx));
765765 }
766766 foreach (PAIRTYPE (const unsigned int , CWalletTx*)& item, mapSorted)
@@ -931,7 +931,8 @@ bool CTransaction::DisconnectInputs(CTxDB& txdb)
931931}
932932
933933
934- bool CTransaction::ConnectInputs (CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx, int nHeight, int64& nFees, bool fBlock , bool fMiner , int64 nMinFee)
934+ bool CTransaction::ConnectInputs (CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
935+ CBlockIndex* pindexBlock, int64& nFees, bool fBlock , bool fMiner , int64 nMinFee)
935936{
936937 // Take over previous transactions' spent pointers
937938 if (!IsCoinBase ())
@@ -983,9 +984,9 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo
983984
984985 // If prev is coinbase, check that it's matured
985986 if (txPrev.IsCoinBase ())
986- for (CBlockIndex* pindex = pindexBest ; pindex && nBestHeight - pindex->nHeight < COINBASE_MATURITY- 1 ; pindex = pindex->pprev )
987+ for (CBlockIndex* pindex = pindexBlock ; pindex && pindexBlock-> nHeight - pindex->nHeight < COINBASE_MATURITY; pindex = pindex->pprev )
987988 if (pindex->nBlockPos == txindex.pos .nBlockPos && pindex->nFile == txindex.pos .nFile )
988- return error (" ConnectInputs() : tried to spend coinbase at depth %d" , nBestHeight - pindex->nHeight );
989+ return error (" ConnectInputs() : tried to spend coinbase at depth %d" , pindexBlock-> nHeight - pindex->nHeight );
989990
990991 // Verify signature
991992 if (!VerifySignature (txPrev, *this , i))
@@ -1019,7 +1020,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo
10191020 if (fBlock )
10201021 {
10211022 // Add transaction to disk index
1022- if (!txdb.AddTxIndex (*this , posThisTx, nHeight))
1023+ if (!txdb.AddTxIndex (*this , posThisTx, pindexBlock-> nHeight ))
10231024 return error (" ConnectInputs() : AddTxPos failed" );
10241025 }
10251026 else if (fMiner )
@@ -1108,7 +1109,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
11081109 CDiskTxPos posThisTx (pindex->nFile , pindex->nBlockPos , nTxPos);
11091110 nTxPos += ::GetSerializeSize (tx, SER_DISK);
11101111
1111- if (!tx.ConnectInputs (txdb, mapUnused, posThisTx, pindex-> nHeight , nFees, true , false ))
1112+ if (!tx.ConnectInputs (txdb, mapUnused, posThisTx, pindex, nFees, true , false ))
11121113 return false ;
11131114 }
11141115
@@ -1379,14 +1380,12 @@ bool CBlock::AcceptBlock()
13791380 return error (" AcceptBlock() : incorrect proof of work" );
13801381
13811382 // Check that the block chain matches the known block chain up to a checkpoint
1382- if (pindexPrev->nHeight +1 == 11111 && hash != uint256 (" 0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d" ))
1383- return error (" AcceptBlock() : rejected by checkpoint lockin at 11111" );
1384- if (pindexPrev->nHeight +1 == 33333 && hash != uint256 (" 0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6" ))
1385- return error (" AcceptBlock() : rejected by checkpoint lockin at 33333" );
1386- if (pindexPrev->nHeight +1 == 68555 && hash != uint256 (" 0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a" ))
1387- return error (" AcceptBlock() : rejected by checkpoint lockin at 68555" );
1388- if (pindexPrev->nHeight +1 == 70567 && hash != uint256 (" 0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a" ))
1389- return error (" AcceptBlock() : rejected by checkpoint lockin at 70567" );
1383+ if ((pindexPrev->nHeight +1 == 11111 && hash != uint256 (" 0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d" )) ||
1384+ (pindexPrev->nHeight +1 == 33333 && hash != uint256 (" 0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6" )) ||
1385+ (pindexPrev->nHeight +1 == 68555 && hash != uint256 (" 0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a" )) ||
1386+ (pindexPrev->nHeight +1 == 70567 && hash != uint256 (" 0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a" )) ||
1387+ (pindexPrev->nHeight +1 == 74000 && hash != uint256 (" 0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20" )))
1388+ return error (" AcceptBlock() : rejected by checkpoint lockin" );
13901389
13911390 // Write block to history file
13921391 if (!CheckDiskSpace (::GetSerializeSize (*this , SER_DISK)))
@@ -2577,6 +2576,8 @@ inline void SHA256Transform(void* pstate, void* pinput, const void* pinit)
25772576 CryptoPP::SHA256::Transform ((CryptoPP::word32*)pstate, (CryptoPP::word32*)pinput);
25782577}
25792578
2579+ static const int NPAR = 32 ;
2580+ extern void Double_BlockSHA256 (const void * pin, void * pout, const void * pinit, unsigned int hash[8 ][NPAR], const void * init2);
25802581
25812582
25822583
@@ -2658,7 +2659,7 @@ void BitcoinMiner()
26582659 int64 nMinFee = tx.GetMinFee (nBlockSize);
26592660
26602661 map<uint256, CTxIndex> mapTestPoolTmp (mapTestPool);
2661- if (!tx.ConnectInputs (txdb, mapTestPoolTmp, CDiskTxPos (1 ,1 ,1 ), 0 , nFees, false , true , nMinFee))
2662+ if (!tx.ConnectInputs (txdb, mapTestPoolTmp, CDiskTxPos (1 ,1 ,1 ), pindexPrev , nFees, false , true , nMinFee))
26622663 continue ;
26632664 swap (mapTestPool, mapTestPoolTmp);
26642665
@@ -2719,14 +2720,40 @@ void BitcoinMiner()
27192720 //
27202721 // Search
27212722 //
2723+ bool f4WaySSE2 = mapArgs.count (" -4way" );
27222724 int64 nStart = GetTime ();
27232725 uint256 hashTarget = CBigNum ().SetCompact (pblock->nBits ).getuint256 ();
27242726 uint256 hashbuf[2 ];
27252727 uint256& hash = *alignup<16 >(hashbuf);
27262728 loop
27272729 {
2728- SHA256Transform (&tmp.hash1 , (char *)&tmp.block + 64 , &midstate);
2729- SHA256Transform (&hash, &tmp.hash1 , pSHA256InitState);
2730+ #ifdef FOURWAYSSE2
2731+ if (f4WaySSE2)
2732+ {
2733+ // tcatm's 4-way SSE2 SHA-256
2734+ tmp.block .nNonce += NPAR;
2735+ unsigned int thashbuf[9 ][NPAR];
2736+ unsigned int (&thash)[9 ][NPAR] = *alignup<16 >(&thashbuf);
2737+ Double_BlockSHA256 ((char *)&tmp.block + 64 , &tmp.hash1 , &midstate, thash, pSHA256InitState);
2738+ ((unsigned short *)&hash)[14 ] = 0xffff ;
2739+ for (int j = 0 ; j < NPAR; j++)
2740+ {
2741+ if (thash[7 ][j] == 0 )
2742+ {
2743+ for (int i = 0 ; i < sizeof (hash)/4 ; i++)
2744+ ((unsigned int *)&hash)[i] = thash[i][j];
2745+ pblock->nNonce = ByteReverse (tmp.block .nNonce + j);
2746+ }
2747+ }
2748+ }
2749+ else
2750+ #endif
2751+ {
2752+ // Crypto++ SHA-256
2753+ tmp.block .nNonce ++;
2754+ SHA256Transform (&tmp.hash1 , (char *)&tmp.block + 64 , &midstate);
2755+ SHA256Transform (&hash, &tmp.hash1 , pSHA256InitState);
2756+ }
27302757
27312758 if (((unsigned short *)&hash)[14 ] == 0 )
27322759 {
@@ -2736,7 +2763,10 @@ void BitcoinMiner()
27362763
27372764 if (hash <= hashTarget)
27382765 {
2739- pblock->nNonce = ByteReverse (tmp.block .nNonce );
2766+ #ifdef FOURWAYSSE2
2767+ if (!f4WaySSE2)
2768+ #endif
2769+ pblock->nNonce = ByteReverse (tmp.block .nNonce );
27402770 assert (hash == pblock->GetHash ());
27412771
27422772 // // debug print
@@ -2775,7 +2805,7 @@ void BitcoinMiner()
27752805 // Update nTime every few seconds
27762806 const unsigned int nMask = 0xffff ;
27772807 const int nHashesPerCycle = (nMask+1 );
2778- if ((++ tmp.block .nNonce & nMask) == 0 )
2808+ if ((tmp.block .nNonce & nMask) == 0 )
27792809 {
27802810 // Meter hashes/sec
27812811 static int nCycleCounter;
0 commit comments