tree checksum vpatch file split hunks
all signers: mircea_popescu trinque asciilifeform ben_vulpes mod6
antecedents: genesis bitcoin-asciilifeform.1
press order:
genesis | asciilifeform ben_vulpes mircea_popescu mod6 trinque |
bitcoin-asciilifeform.1 | asciilifeform ben_vulpes mod6 |
rm_rf_upnp | asciilifeform ben_vulpes mod6 |
patch:
(927 . 7)(927 . 6)- 0A8227F07119A5AC88E550780A2C74482859D71119F19CE45096044703826751850F64EE5F06B57E4A0641F61D9D1A9F4C55946EE2EBA25AA192F9A334A7AE8A
5 if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose;
6 if (strKey == "fUseProxy") ssValue >> fUseProxy;
7 if (strKey == "addrProxy") ssValue >> addrProxy;
8 if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
9 }
10 else if (strType == "minversion")
11 {
(950 . 9)(949 . 6)
13 printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
14 printf("fUseProxy = %d\n", fUseProxy);
15 printf("addrProxy = %s\n", addrProxy.ToString().c_str());
16 if (fHaveUPnP)
17 printf("fUseUPnP = %d\n", fUseUPnP);
18
19
20 // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
21 if (fIsEncrypted && (nFileVersion == 40000 || nFileVersion == 50000))
(188 . 13)(188 . 6)- E37A9EB6A10745A2B0F52AACD915809961D5663185CCE5792862579D340D6C98C1633A669A04FCD76835839EE13FDA982E9B8ED3F190DE24583F1A50167DEE3B
26 " -bantime=<n> \t " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)\n") +
27 " -maxreceivebuffer=<n>\t " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)\n") +
28 " -maxsendbuffer=<n>\t " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)\n") +
29 #ifdef USE_UPNP
30 #if USE_UPNP
31 " -noupnp \t " + _("Don't attempt to use UPnP to map the listening port\n") +
32 #else
33 " -upnp \t " + _("Attempt to use UPnP to map the listening port\n") +
34 #endif
35 #endif
36 " -paytxfee=<amt> \t " + _("Fee per kB to add to transactions you send\n") +
37 #if !defined(WIN32)
38 " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
(460 . 8)(453 . 6)
40 SoftSetArg("-nolisten", true);
41 SoftSetArg("-noirc", true);
42 SoftSetArg("-nodnsseed", true);
43 SoftSetArg("-noupnp", true);
44 SoftSetArg("-upnp", false);
45 SoftSetArg("-dns", false);
46 }
47
(469 . 10)(460 . 6)
49 fNoListen = GetBoolArg("-nolisten");
50
51 // Command-line args override in-wallet settings:
52 if (mapArgs.count("-upnp"))
53 fUseUPnP = GetBoolArg("-upnp");
54 else if (mapArgs.count("-noupnp"))
55 fUseUPnP = !GetBoolArg("-noupnp");
56
57 if (!fNoListen)
58 {
(57 . 11)(57 . 6)
63 int nLimitProcessors = 1;
64 int fMinimizeToTray = true;
65 int fMinimizeOnClose = true;
66 #if USE_UPNP
67 int fUseUPnP = true;
68 #else
69 int fUseUPnP = false;
70 #endif
71
72
73 //////////////////////////////////////////////////////////////////////////////
- 06542E40FA8B01BBFE6964E46B6FFDF605E42F2DAAD2A14A64C3D70FD72A3ADDA5ADE3ADAE4D5016397F2C98249583D9B72462FF66E7EA4704E20083A639094A(40 . 11)(40 . 6)- A2BBF273FB5D7681B473C79C9E8CA64EABA740E76B4D7276072CDF2D36726D83E92744344A31016CC05104C54DF4A9B030B429F1DA32A095243555DCC61AF2CC
78 static const int COINBASE_MATURITY = 100;
79 // Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
80 static const int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
81 #ifdef USE_UPNP
82 static const int fHaveUPnP = true;
83 #else
84 static const int fHaveUPnP = false;
85 #endif
86
87
88
(74 . 7)(69 . 6)
90 extern int nLimitProcessors;
91 extern int fMinimizeToTray;
92 extern int fMinimizeOnClose;
93 extern int fUseUPnP;
94
95
96
(4 . 8)(4 . 6)- E7748EE5E13EDD5B95C8FFCD5F4909FF4F7CF98961A7581028ADAF25F6FF79CA51D520811D06FCA8CED7EFA1FEC31E5F06E90F672B8C37B3D62ACF50EE744C01
101
102 DEPSDIR:=/usr/i586-mingw32msvc
103
104 USE_UPNP:=0
105
106 INCLUDEPATHS= \
107 -I"$(DEPSDIR)/boost_1_47_0" \
108 -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
(53 . 11)(51 . 6)
110 wallet.h
111
112
113 ifdef USE_UPNP
114 LIBPATHS += -L"$(DEPSDIR)/miniupnpc"
115 LIBS += -l miniupnpc -l iphlpapi
116 DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
117 endif
118
119 LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi
120
(2 . 8)(2 . 6)- B72B573BA77B095E2497E297BA5B02AA68317F67438EE070FEE86E129A95B85DC9B5CA98E96441BB2B3B98263DD88630990C913AFFBABF890641F349D1C6DA47
125 # Distributed under the MIT/X11 software license, see the accompanying
126 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
127
128 USE_UPNP:=0
129
130 DEFS=-DNOPCH
131
132 DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
(31 . 14)(29 . 6)
134 -l ssl \
135 -l crypto
136
137 ifndef USE_UPNP
138 override USE_UPNP = -
139 endif
140 ifneq (${USE_UPNP}, -)
141 LIBS += -l miniupnpc
142 DEFS += -DUSE_UPNP=$(USE_UPNP)
143 endif
144
145 ifneq (${USE_SSL}, 0)
146 DEFS += -DUSE_SSL
147 endif
(14 . 12)(14 . 6)
152 #include <string.h>
153 #endif
154
155 #ifdef USE_UPNP
156 #include <miniupnpc/miniwget.h>
157 #include <miniupnpc/miniupnpc.h>
158 #include <miniupnpc/upnpcommands.h>
159 #include <miniupnpc/upnperrors.h>
160 #endif
161
162 using namespace std;
163 using namespace boost;
(29 . 9)(23 . 6)
165 void ThreadMessageHandler2(void* parg);
166 void ThreadSocketHandler2(void* parg);
167 void ThreadOpenConnections2(void* parg);
168 #ifdef USE_UPNP
169 void ThreadMapPort2(void* parg);
170 #endif
171 void ThreadDNSAddressSeed2(void* parg);
172 bool OpenNetworkConnection(const CAddress& addrConnect);
173
(1110 . 153)(1101 . 6)
175
176
177
178 #ifdef USE_UPNP
179 void ThreadMapPort(void* parg)
180 {
181 IMPLEMENT_RANDOMIZE_STACK(ThreadMapPort(parg));
182 try
183 {
184 vnThreadsRunning[5]++;
185 ThreadMapPort2(parg);
186 vnThreadsRunning[5]--;
187 }
188 catch (std::exception& e) {
189 vnThreadsRunning[5]--;
190 PrintException(&e, "ThreadMapPort()");
191 } catch (...) {
192 vnThreadsRunning[5]--;
193 PrintException(NULL, "ThreadMapPort()");
194 }
195 printf("ThreadMapPort exiting\n");
196 }
197
198 void ThreadMapPort2(void* parg)
199 {
200 printf("ThreadMapPort started\n");
201
202 char port[6];
203 sprintf(port, "%d", GetListenPort());
204
205 const char * multicastif = 0;
206 const char * minissdpdpath = 0;
207 struct UPNPDev * devlist = 0;
208 char lanaddr[64];
209
210 #ifndef UPNPDISCOVER_SUCCESS
211 /* miniupnpc 1.5 */
212 devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0);
213 #else
214 /* miniupnpc 1.6 */
215 int error = 0;
216 devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error);
217 #endif
218
219 struct UPNPUrls urls;
220 struct IGDdatas data;
221 int r;
222
223 r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
224 if (r == 1)
225 {
226 if (!addrLocalHost.IsRoutable())
227 {
228 char externalIPAddress[40];
229 r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress);
230 if(r != UPNPCOMMAND_SUCCESS)
231 printf("UPnP: GetExternalIPAddress() returned %d\n", r);
232 else
233 {
234 if(externalIPAddress[0])
235 {
236 printf("UPnP: ExternalIPAddress = %s\n", externalIPAddress);
237 CAddress addrExternalFromUPnP(externalIPAddress, 0, false, nLocalServices);
238 if (addrExternalFromUPnP.IsRoutable())
239 addrLocalHost = addrExternalFromUPnP;
240 }
241 else
242 printf("UPnP: GetExternalIPAddress failed.\n");
243 }
244 }
245
246 string strDesc = "Bitcoin " + FormatFullVersion();
247 #ifndef UPNPDISCOVER_SUCCESS
248 /* miniupnpc 1.5 */
249 r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
250 port, port, lanaddr, strDesc.c_str(), "TCP", 0);
251 #else
252 /* miniupnpc 1.6 */
253 r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
254 port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0");
255 #endif
256
257 if(r!=UPNPCOMMAND_SUCCESS)
258 printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
259 port, port, lanaddr, r, strupnperror(r));
260 else
261 printf("UPnP Port Mapping successful.\n");
262 int i = 1;
263 loop {
264 if (fShutdown || !fUseUPnP)
265 {
266 r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port, "TCP", 0);
267 printf("UPNP_DeletePortMapping() returned : %d\n", r);
268 freeUPNPDevlist(devlist); devlist = 0;
269 FreeUPNPUrls(&urls);
270 return;
271 }
272 if (i % 600 == 0) // Refresh every 20 minutes
273 {
274 #ifndef UPNPDISCOVER_SUCCESS
275 /* miniupnpc 1.5 */
276 r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
277 port, port, lanaddr, strDesc.c_str(), "TCP", 0);
278 #else
279 /* miniupnpc 1.6 */
280 r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
281 port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0");
282 #endif
283
284 if(r!=UPNPCOMMAND_SUCCESS)
285 printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
286 port, port, lanaddr, r, strupnperror(r));
287 else
288 printf("UPnP Port Mapping successful.\n");;
289 }
290 Sleep(2000);
291 i++;
292 }
293 } else {
294 printf("No valid UPnP IGDs found\n");
295 freeUPNPDevlist(devlist); devlist = 0;
296 if (r != 0)
297 FreeUPNPUrls(&urls);
298 loop {
299 if (fShutdown || !fUseUPnP)
300 return;
301 Sleep(2000);
302 }
303 }
304 }
305
306 void MapPort(bool fMapPort)
307 {
308 if (fUseUPnP != fMapPort)
309 {
310 fUseUPnP = fMapPort;
311 WriteSetting("fUseUPnP", fUseUPnP);
312 }
313 if (fUseUPnP && vnThreadsRunning[5] < 1)
314 {
315 if (!CreateThread(ThreadMapPort, NULL))
316 printf("Error: ThreadMapPort(ThreadMapPort) failed\n");
317 }
318 }
319 #else
320 void MapPort(bool /* unused fMapPort */)
321 {
322 // Intentionally left blank.
323 }
324 #endif
325
326
327
(1872 . 10)(1716 . 6)
329 if (!CreateThread(ThreadDNSAddressSeed, NULL))
330 printf("Error: CreateThread(ThreadDNSAddressSeed) failed\n");
331
332 // Map ports with UPnP
333 if (fHaveUPnP)
334 MapPort(fUseUPnP);
335
336 // Get addresses from IRC and advertise ours
337 if (!CreateThread(ThreadIRCSeed, NULL))
338 printf("Error: CreateThread(ThreadIRCSeed) failed\n");
(1903 . 9)(1743 . 6)
340 nTransactionsUpdated++;
341 int64 nStart = GetTime();
342 while (vnThreadsRunning[0] > 0 || vnThreadsRunning[1] > 0 || vnThreadsRunning[2] > 0 || vnThreadsRunning[3] > 0 || vnThreadsRunning[4] > 0
343 #ifdef USE_UPNP
344 || vnThreadsRunning[5] > 0
345 #endif
346 )
347 {
348 if (GetTime() - nStart > 20)
(1917 . 7)(1754 . 6)
350 if (vnThreadsRunning[2] > 0) printf("ThreadMessageHandler still running\n");
351 if (vnThreadsRunning[3] > 0) printf("ThreadBitcoinMiner still running\n");
352 if (vnThreadsRunning[4] > 0) printf("ThreadRPCServer still running\n");
353 if (fHaveUPnP && vnThreadsRunning[5] > 0) printf("ThreadMapPort still running\n");
354 if (vnThreadsRunning[6] > 0) printf("ThreadDNSAddressSeed still running\n");
355 while (vnThreadsRunning[2] > 0 || vnThreadsRunning[4] > 0)
356 Sleep(20);