tree checksum vpatch file split hunks

all signers: mircea_popescu trinque asciilifeform ben_vulpes mod6

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

press order:

genesisasciilifeform ben_vulpes mircea_popescu mod6 trinque
bitcoin-asciilifeform.1asciilifeform ben_vulpes mod6
rm_rf_upnpasciilifeform ben_vulpes mod6
bitcoin-asciilifeform.3-turdmeister-alert-snipasciilifeform ben_vulpes mod6
asciilifeform_orphanage_thermonukeasciilifeform ben_vulpes mod6
bitcoin-asciilifeform.2-https_snipsnipasciilifeform ben_vulpes mod6
bitcoin-asciilifeform.4-goodbye-win32asciilifeform ben_vulpes mod6
asciilifeform_tx-orphanage_amputationasciilifeform ben_vulpes mod6

patch:

- FE5DCF6804D4FDAA80F20EBDCD4FDFEAFE0FA4108818A6574B5A6123790E7CDB38CCB612078AF5AC8EE42E5F3C3E525E62E29A041F5AB5EBEBAF929950AE5AAC
+ 18A4B9A7ABCCAC46895C8EEB0C14CC502F3743958654444C87D5192A51073980858750DAA9C8BD67F4D4D2EC8A7117AEA8FC75A4ACF73CC1A2CAB996AEA324B1
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 }
- 8CFDDA6FD46E07E50AB42E4F4652274C324B6020F30A340B6BB9EE3FD620C497473C8480102218D48261646D7ADFECFF7FF987F8A798997B4D3EBD032066D78D
+ FF2BF8F8147DD8DF5E1EF1BCEA9B0159D3F83C1E30BEFEF56415B99305AA99161AC1C05EFB48BE87A383FFB6D621FD3761BFB3E4952CA244A6E1398CA3C71DC6
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;