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