tree checksum vpatch file split hunks
all signers: mircea_popescu trinque asciilifeform ben_vulpes mod6
antecedents: bitcoin-asciilifeform.3-turdmeister-alert-snip
press order:
patch:
(40 . 9)(40 . 6)
5
6 CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
7
8 map<uint256, CBlock*> mapOrphanBlocks;
9 multimap<uint256, CBlock*> mapOrphanBlocksByPrev;
10
11 map<uint256, CDataStream*> mapOrphanTransactions;
12 multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;
13
(654 . 14)(651 . 6)
15 return true;
16 }
17
18 uint256 static GetOrphanRoot(const CBlock* pblock)
19 {
20 // Work back to the first block in the orphan chain
21 while (mapOrphanBlocks.count(pblock->hashPrevBlock))
22 pblock = mapOrphanBlocks[pblock->hashPrevBlock];
23 return pblock->GetHash();
24 }
25
26 int64 static GetBlockValue(int nHeight, int64 nFees)
27 {
28 int64 nSubsidy = 50 * COIN;
(1427 . 8)(1416 . 6)
30 uint256 hash = pblock->GetHash();
31 if (mapBlockIndex.count(hash))
32 return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str());
33 if (mapOrphanBlocks.count(hash))
34 return error("ProcessBlock() : already have block (orphan) %s", hash.ToString().substr(0,20).c_str());
35
36 // Preliminary checks
37 if (!pblock->CheckBlock())
(1457 . 44)(1444 . 22)
39 }
40 }
41
42
43 // If don't already have its previous block, shunt it off to holding area until we get it
44 // If don't already have its previous block, throw it out!
45 if (!mapBlockIndex.count(pblock->hashPrevBlock))
46 {
47 printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str());
48 CBlock* pblock2 = new CBlock(*pblock);
49 mapOrphanBlocks.insert(make_pair(hash, pblock2));
50 mapOrphanBlocksByPrev.insert(make_pair(pblock2->hashPrevBlock, pblock2));
51 printf("ProcessBlock: BASTARD BLOCK, prev=%s, DISCARDED\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str());
52
53 // Ask this guy to fill in what we're missing
54 if (pfrom)
55 pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(pblock2));
56 return true;
57 pfrom->PushGetBlocks(pindexBest, pblock->hashPrevBlock);
58
59 return true;
60 }
61
62 // Store to disk
63 if (!pblock->AcceptBlock())
64 return error("ProcessBlock() : AcceptBlock FAILED");
65
66 // Recursively process any orphan blocks that depended on this one
67 vector<uint256> vWorkQueue;
68 vWorkQueue.push_back(hash);
69 for (int i = 0; i < vWorkQueue.size(); i++)
70 {
71 uint256 hashPrev = vWorkQueue[i];
72 for (multimap<uint256, CBlock*>::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev);
73 mi != mapOrphanBlocksByPrev.upper_bound(hashPrev);
74 ++mi)
75 {
76 CBlock* pblockOrphan = (*mi).second;
77 if (pblockOrphan->AcceptBlock())
78 vWorkQueue.push_back(pblockOrphan->GetHash());
79 mapOrphanBlocks.erase(pblockOrphan->GetHash());
80 delete pblockOrphan;
81 }
82 mapOrphanBlocksByPrev.erase(hashPrev);
83 }
84
85 printf("ProcessBlock: ACCEPTED\n");
86 return true;
87 }
(1767 . 7)(1732 . 7)
89 switch (inv.type)
90 {
91 case MSG_TX: return mapTransactions.count(inv.hash) || mapOrphanTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash);
92 case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash);
93 case MSG_BLOCK: return mapBlockIndex.count(inv.hash);
94 }
95 // Don't know what it is, just say we already got one
96 return true;
(1989 . 8)(1954 . 6)
98
99 if (!fAlreadyHave)
100 pfrom->AskFor(inv);
101 else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash))
102 pfrom->PushGetBlocks(pindexBest, GetOrphanRoot(mapOrphanBlocks[inv.hash]));
103
104 // Track requests for our stuff
105 Inventory(inv.hash);