tree checksum vpatch file split hunks

all signers: mod6

antecedents: bitcoin-asciilifeform.4-goodbye-win32 asciilifeform_orphanage_thermonuke

press order:

genesismod6
bitcoin-asciilifeform.1mod6
rm_rf_upnpmod6
bitcoin-asciilifeform.3-turdmeister-alert-snipmod6
asciilifeform_orphanage_thermonukemod6
bitcoin-asciilifeform.2-https_snipsnipmod6
bitcoin-asciilifeform.4-goodbye-win32mod6
asciilifeform_tx-orphanage_amputationmod6

patch:

- 61852C7C9D4C69AE3E686A3BE199BB692875D8E28845D47153B020DD904D08658A10B9AC0437BE4AF4036DDEDB64DC6F0AE5952E9A491D34E0C35763AFA1CE94
+ 537A12D62802FA25331CE5E27434A9AF18F263BBCC4D9CB4092E8C72C314B7A1CE6ACB20CFDC3CE17A7668302F466BC5041D7E5A40F7C4531C411A40C86FF767
bitcoin/src/main.cpp
(40 . 8)(40 . 6)
5
6 CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have
7
8 map<uint256, CDataStream*> mapOrphanTransactions;
9 multimap<uint256, CDataStream*> mapOrphanTransactionsByPrev;
10
11
12 double dHashesPerSec;
(148 . 75)(146 . 6)
14 }
15
16
17
18
19
20
21
22 //////////////////////////////////////////////////////////////////////////////
23 //
24 // mapOrphanTransactions
25 //
26
27 void AddOrphanTx(const CDataStream& vMsg)
28 {
29 CTransaction tx;
30 CDataStream(vMsg) >> tx;
31 uint256 hash = tx.GetHash();
32 if (mapOrphanTransactions.count(hash))
33 return;
34
35 CDataStream* pvMsg = mapOrphanTransactions[hash] = new CDataStream(vMsg);
36 BOOST_FOREACH(const CTxIn& txin, tx.vin)
37 mapOrphanTransactionsByPrev.insert(make_pair(txin.prevout.hash, pvMsg));
38 }
39
40 void static EraseOrphanTx(uint256 hash)
41 {
42 if (!mapOrphanTransactions.count(hash))
43 return;
44 const CDataStream* pvMsg = mapOrphanTransactions[hash];
45 CTransaction tx;
46 CDataStream(*pvMsg) >> tx;
47 BOOST_FOREACH(const CTxIn& txin, tx.vin)
48 {
49 for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(txin.prevout.hash);
50 mi != mapOrphanTransactionsByPrev.upper_bound(txin.prevout.hash);)
51 {
52 if ((*mi).second == pvMsg)
53 mapOrphanTransactionsByPrev.erase(mi++);
54 else
55 mi++;
56 }
57 }
58 delete pvMsg;
59 mapOrphanTransactions.erase(hash);
60 }
61
62 int LimitOrphanTxSize(int nMaxOrphans)
63 {
64 int nEvicted = 0;
65 while (mapOrphanTransactions.size() > nMaxOrphans)
66 {
67 // Evict a random orphan:
68 std::vector<unsigned char> randbytes(32);
69 RAND_bytes(&randbytes[0], 32);
70 uint256 randomhash(randbytes);
71 map<uint256, CDataStream*>::iterator it = mapOrphanTransactions.lower_bound(randomhash);
72 if (it == mapOrphanTransactions.end())
73 it = mapOrphanTransactions.begin();
74 EraseOrphanTx(it->first);
75 ++nEvicted;
76 }
77 return nEvicted;
78 }
79
80
81
82
83
84
85
86 //////////////////////////////////////////////////////////////////////////////
87 //
88 // CTransaction and CTxIndex
(1731 . 7)(1660 . 7)
90 {
91 switch (inv.type)
92 {
93 case MSG_TX: return mapTransactions.count(inv.hash) || mapOrphanTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash);
94 case MSG_TX: return mapTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash);
95 case MSG_BLOCK: return mapBlockIndex.count(inv.hash);
96 }
97 // Don't know what it is, just say we already got one
(2108 . 43)(2037 . 10)
99 RelayMessage(inv, vMsg);
100 mapAlreadyAskedFor.erase(inv);
101 vWorkQueue.push_back(inv.hash);
102
103 // Recursively process any orphan transactions that depended on this one
104 for (int i = 0; i < vWorkQueue.size(); i++)
105 {
106 uint256 hashPrev = vWorkQueue[i];
107 for (multimap<uint256, CDataStream*>::iterator mi = mapOrphanTransactionsByPrev.lower_bound(hashPrev);
108 mi != mapOrphanTransactionsByPrev.upper_bound(hashPrev);
109 ++mi)
110 {
111 const CDataStream& vMsg = *((*mi).second);
112 CTransaction tx;
113 CDataStream(vMsg) >> tx;
114 CInv inv(MSG_TX, tx.GetHash());
115
116 if (tx.AcceptToMemoryPool(true))
117 {
118 printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
119 SyncWithWallets(tx, NULL, true);
120 RelayMessage(inv, vMsg);
121 mapAlreadyAskedFor.erase(inv);
122 vWorkQueue.push_back(inv.hash);
123 }
124 }
125 }
126
127 BOOST_FOREACH(uint256 hash, vWorkQueue)
128 EraseOrphanTx(hash);
129 }
130 else if (fMissingInputs)
131 {
132 printf("storing orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
133 AddOrphanTx(vMsg);
134
135 // DoS prevention: do not allow mapOrphanTransactions to grow unbounded
136 int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS);
137 if (nEvicted > 0)
138 printf("mapOrphan overflow, removed %d tx\n", nEvicted);
139 printf("REJECTED orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
140 }
141 if (tx.nDoS) pfrom->Misbehaving(tx.nDoS);
142 }
- 66AF7BED57921718A5E073DB591E4DC838622DF4AF4E5662A0B2F46F20EE60C98FEC6D967BDB71A4C1CF82E3DC9F2F6E0AEDDAEF9C7246B7797E6B4DB5F1080D
+ ECAFBDF451A63BE8EA30BA33B93F62A155511051154AF8369284519E6F493D2B3546FF2D3E7F7A3EC263F50A2080DA9665B24DCE3AEBB4CD54B92ACB12F37024
bitcoin/src/main.h
(30 . 7)(30 . 6)
147 static const unsigned int MAX_BLOCK_SIZE = 1000000;
148 static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2;
149 static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
150 static const int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100;
151 static const int64 COIN = 100000000;
152 static const int64 CENT = 1000000;
153 static const int64 MIN_TX_FEE = 50000;