- E76829B2488665287ED6037EAA5DD4651A67DDC9A44111089F55249248B6549387B9146BB1E51CC5A659558805BCF8987C10ECAD8478F83FC5EB165044AC5D3C
+ 91083AA2A87B340863C1A6E1D12075DAB306D8342813B4CADC383218E54657CA2A082AFB6067CC3CF42752504E850B619EC40809D7DD433524487D88C4B19E7E
bitcoin/src/main.cpp
(365 . 8)(365 . 8)
32 if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, 0, fInvalid))
33 {
34 if (fInvalid)
35 return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().substr(0,10).c_str());
36 return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str());
37 return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().c_str());
38 return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().c_str());
39 }
40
41 // Don't accept it if it can't get into a block
(415 . 7)(415 . 7)
43 if (ptxOld)
44 EraseFromWallets(ptxOld->GetHash());
45
46 printf("AcceptToMemoryPool(): accepted %s\n", hash.ToString().substr(0,10).c_str());
47 printf("AcceptToMemoryPool(): accepted %s\n", hash.ToString().c_str());
48 return true;
49 }
50
(709 . 8)(709 . 8)
52 CTxDB().WriteBestInvalidWork(bnBestInvalidWork);
53 MainFrameRepaint();
54 }
55 printf("InvalidChainFound: invalid block=%s height=%d work=%s\n", pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, pindexNew->bnChainWork.ToString().c_str());
56 printf("InvalidChainFound: current best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
57 printf("InvalidChainFound: invalid block=%s height=%d work=%s\n", pindexNew->GetBlockHash().ToString().c_str(), pindexNew->nHeight, pindexNew->bnChainWork.ToString().c_str());
58 printf("InvalidChainFound: current best=%s height=%d work=%s\n", hashBestChain.ToString().c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
59 if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6)
60 printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n");
61 }
(796 . 7)(796 . 7)
63 fFound = txdb.ReadTxIndex(prevout.hash, txindex);
64 }
65 if (!fFound && (fBlock || fMiner))
66 return fMiner ? false : error("ConnectInputs() : %s prev tx %s index entry not found", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
67 return fMiner ? false : error("ConnectInputs() : %s prev tx %s index entry not found", GetHash().ToString().c_str(), prevout.hash.ToString().c_str());
68
69 // Read txPrev
70 CTransaction txPrev;
(806 . 7)(806 . 7)
72 CRITICAL_BLOCK(cs_mapTransactions)
73 {
74 if (!mapTransactions.count(prevout.hash))
75 return error("ConnectInputs() : %s mapTransactions prev not found %s", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
76 return error("ConnectInputs() : %s mapTransactions prev not found %s", GetHash().ToString().c_str(), prevout.hash.ToString().c_str());
77 txPrev = mapTransactions[prevout.hash];
78 }
79 if (!fFound)
(816 . 7)(816 . 7)
81 {
82 // Get prev tx from disk
83 if (!txPrev.ReadFromDisk(txindex.pos))
84 return error("ConnectInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str());
85 return error("ConnectInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().c_str(), prevout.hash.ToString().c_str());
86 }
87
88 if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size())
(824 . 7)(824 . 7)
90 // Revisit this if/when transaction replacement is implemented and allows
91 // adding inputs:
92 fInvalid = true;
93 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()));
94 return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().c_str(), txPrev.ToString().c_str()));
95 }
96
97 // If prev is coinbase, check that it's matured
(839 . 13)(839 . 13)
99 if (fVerifyAll || (!(fBlock && (nBestHeight < Checkpoints::GetTotalBlocksEstimate()))))
100 // Verify signature
101 if (!VerifySignature(txPrev, *this, i))
102 return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
103 return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().c_str()));
104
105 // Check for conflicts (double-spend)
106 // This doesn't trigger the DoS code on purpose; if it did, it would make it easier
107 // for an attacker to attempt to split the network.
108 if (!txindex.vSpent[prevout.n].IsNull())
109 return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,10).c_str(), txindex.vSpent[prevout.n].ToString().c_str());
110 return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().c_str(), txindex.vSpent[prevout.n].ToString().c_str());
111
112 // Check for negative or overflow input values
113 nValueIn += txPrev.vout[prevout.n].nValue;
(863 . 12)(863 . 12)
115 }
116
117 if (nValueIn < GetValueOut())
118 return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
119 return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString().c_str()));
120
121 // Tally transaction fees
122 int64 nTxFee = nValueIn - GetValueOut();
123 if (nTxFee < 0)
124 return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().substr(0,10).c_str()));
125 return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString().c_str()));
126 if (nTxFee < nMinFee)
127 return false;
128 nFees += nTxFee;
(1174 . 7)(1174 . 7)
130 bnBestChainWork = pindexNew->bnChainWork;
131 nTimeBestReceived = GetTime();
132 nTransactionsUpdated++;
133 printf("SetBestChain: new best=%s height=%d work=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
134 printf("SetBestChain: new best=%s height=%d work=%s\n", hashBestChain.ToString().c_str(), nBestHeight, bnBestChainWork.ToString().c_str());
135
136 return true;
137 }
(1185 . 7)(1185 . 7)
139 // Check for duplicate
140 uint256 hash = GetHash();
141 if (mapBlockIndex.count(hash))
142 return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str());
143 return error("AddToBlockIndex() : %s already exists", hash.ToString().c_str());
144
145 // Construct new block index object
146 CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this);
(1325 . 7)(1325 . 7)
148 // Check for duplicate
149 uint256 hash = pblock->GetHash();
150 if (mapBlockIndex.count(hash))
151 return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str());
152 return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().c_str());
153
154 // Preliminary checks
155 if (!pblock->CheckBlock())
(1357 . 7)(1357 . 7)
157 // If don't already have its previous block, throw it out!
158 if (!mapBlockIndex.count(pblock->hashPrevBlock))
159 {
160 printf("ProcessBlock: BASTARD BLOCK, prev=%s, DISCARDED\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str());
161 printf("ProcessBlock: BASTARD BLOCK, prev=%s, DISCARDED\n", pblock->hashPrevBlock.ToString().c_str());
162
163 // Ask this guy to fill in what we're missing
164 if (pfrom)
(1553 . 7)(1553 . 7)
166 pindex->nHeight,
167 pindex->nFile,
168 pindex->nBlockPos,
169 block.GetHash().ToString().substr(0,20).c_str(),
170 block.GetHash().ToString().c_str(),
171 DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()).c_str(),
172 block.vtx.size());
173
(1925 . 12)(1925 . 12)
175 pindex = pindex->pnext;
176 int nLimit = 500 + locator.GetDistanceBack();
177 unsigned int nBytes = 0;
178 printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);
179 printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit);
180 for (; pindex; pindex = pindex->pnext)
181 {
182 if (pindex->GetBlockHash() == hashStop)
183 {
184 printf(" getblocks stopping at %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes);
185 printf(" getblocks stopping at %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str(), nBytes);
186 break;
187 }
188 pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash()));
(1941 . 7)(1941 . 7)
190 {
191 // When this block is requested, we'll send an inv that'll make them
192 // getblocks the next batch of inventory.
193 printf(" getblocks stopping at limit %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes);
194 printf(" getblocks stopping at limit %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str(), nBytes);
195 pfrom->hashContinue = pindex->GetBlockHash();
196 break;
197 }
(1974 . 7)(1974 . 7)
199
200 vector<CBlock> vHeaders;
201 int nLimit = 2000 + locator.GetDistanceBack();
202 printf("getheaders %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit);
203 printf("getheaders %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().c_str(), nLimit);
204 for (; pindex; pindex = pindex->pnext)
205 {
206 vHeaders.push_back(pindex->GetBlockHeader());
(2005 . 7)(2005 . 7)
208 }
209 else if (fMissingInputs)
210 {
211 printf("REJECTED orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
212 printf("REJECTED orphan tx %s\n", inv.hash.ToString().c_str());
213 }
214 if (tx.nDoS) pfrom->Misbehaving(tx.nDoS);
215 }
(2016 . 7)(2016 . 7)
217 CBlock block;
218 vRecv >> block;
219
220 printf("received block %s\n", block.GetHash().ToString().substr(0,20).c_str());
221 printf("received block %s\n", block.GetHash().ToString().c_str());
222 // block.print();
223
224 CInv inv(MSG_BLOCK, block.GetHash());
(2524 . 9)(2524 . 9)
226
227 void print() const
228 {
229 printf("COrphan(hash=%s, dPriority=%.1f)\n", ptx->GetHash().ToString().substr(0,10).c_str(), dPriority);
230 printf("COrphan(hash=%s, dPriority=%.1f)\n", ptx->GetHash().ToString().c_str(), dPriority);
231 BOOST_FOREACH(uint256 hash, setDependsOn)
232 printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str());
233 printf(" setDependsOn %s\n", hash.ToString().c_str());
234 }
235 };
236
(2608 . 7)(2608 . 7)
238
239 if (fDebug && GetBoolArg("-printpriority"))
240 {
241 printf("priority %-20.1f %s\n%s", dPriority, tx.GetHash().ToString().substr(0,10).c_str(), tx.ToString().c_str());
242 printf("priority %-20.1f %s\n%s", dPriority, tx.GetHash().ToString().c_str(), tx.ToString().c_str());
243 if (porphan)
244 porphan->print();
245 printf("\n");