tree checksum vpatch file split hunks

all signers: mircea_popescu trinque asciilifeform ben_vulpes mod6

antecedents: bitcoin-asciilifeform.3-turdmeister-alert-snip bitcoin-asciilifeform.1 rm_rf_upnp genesis bitcoin-asciilifeform.2-https_snipsnip

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
bitcoin-asciilifeform.2-https_snipsnipasciilifeform ben_vulpes mod6
bitcoin-asciilifeform.4-goodbye-win32asciilifeform ben_vulpes mod6

patch:

- BE601828DA9D44E686E4FB5341373A1559642121A92080BD9DDB223C7DCB2BAC08BA6236653645EB5A458D5FE05DE7B4FD14F590975477E952F5D667AE049ADC
+ BC6C82AB1A129E9E74A6BF785DF99AC939FEF94D72AFBEE153913FD53CAB5D05120047275342CB4D52A98A951184EED47CCCD9710E3655C261B68D2F257614A3
bitcoin/src/bitcoinrpc.cpp
(2422 . 11)(2422 . 6)
5 #ifdef TEST
6 int main(int argc, char *argv[])
7 {
8 #ifdef _MSC_VER
9 // Turn off microsoft heap dump noise
10 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
11 _CrtSetReportFile(_CRT_WARN, CreateFile("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
12 #endif
13 setbuf(stdin, NULL);
14 setbuf(stdout, NULL);
15 setbuf(stderr, NULL);
- 64DDDC1348603EA005F4F5297EA6D51074FEAD3DD8D1256C1A4C2A678FEF1ABCB58D148EBB9EB3716E200E27ABF6D07C19D1CF6FCBB4E1B9DCBA59FDE8EAE324
+ 195BDE01368DC6B69E0F9D5046B2DD83F1F2345393E88382A3838EFAC8B6635C5992F2F8599D0AD3913B4A4B8C144CAD7C7E714E7C2F96AA15A86BA820B27321
bitcoin/src/crypter.cpp
(7 . 9)(7 . 6)
20 #include <vector>
21 #include <string>
22 #include "headers.h"
23 #ifdef WIN32
24 #include <windows.h>
25 #endif
26
27 #include "crypter.h"
28 #include "main.h"
- C5AA0633F19E5ED97F1D80509A84BD8AEEB42ADE44EB1B45A1220C429B78C3943A2DFC83DA82FA9CDB87DC9563A1278D2033C20B5E2DA83252E36407A470DF93
+ 66F81F6DA997109F4D34CA654D30E24CB850FA87A6FBE6A045C6CB1A9F6D47D979FB4E25A0BBB35064C1259CDA3C7B5FF12F68D9C22C1ACF45299DBB4ED72317
bitcoin/src/db.cpp
(768 . 11)(768 . 9)
33 bool fIsEncrypted = false;
34
35 // Modify defaults
36 #ifndef WIN32
37 // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program
38 fMinimizeToTray = false;
39 fMinimizeOnClose = false;
40 #endif
41
42 //// todo: shouldn't we catch exceptions and try to recover and continue?
43 CRITICAL_BLOCK(pwallet->cs_wallet)
- 5FA4D450D3F50651EEB12E3DE9657C1A8A3968D37F2DF15A7C1F7B0AD44FDBD427D8934F0CF81DF00F6EAC9A456A80ADF7CBC2882678AC943C207EDE1C2F637A
+ B86114B5B74D2B9E737798F78804439C5CDD0AE42440615C57FC85CB0AC7D8B8A454D2EF44048DB6AF0CA00A938178173EECE431B273462DBC299C1501B86600
bitcoin/src/headers.h
(3 . 22)(3 . 6)
48 // Distributed under the MIT/X11 software license, see the accompanying
49 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
50
51 #ifdef _MSC_VER
52 #pragma warning(disable:4786)
53 #pragma warning(disable:4804)
54 #pragma warning(disable:4805)
55 #pragma warning(disable:4717)
56 #endif
57 #ifdef _WIN32_WINNT
58 #undef _WIN32_WINNT
59 #endif
60 #define _WIN32_WINNT 0x0500
61 #ifdef _WIN32_IE
62 #undef _WIN32_IE
63 #endif
64 #define _WIN32_IE 0x0400
65 #define WIN32_LEAN_AND_MEAN 1
66
67 // Include boost/foreach here as it defines __STDC_LIMIT_MACROS on some systems.
68 #include <boost/foreach.hpp>
69 #ifndef __STDC_LIMIT_MACROS
(55 . 16)(39 . 6)
71 #include <deque>
72 #include <map>
73
74 #ifdef WIN32
75 #include <windows.h>
76 #include <winsock2.h>
77 #include <mswsock.h>
78 #include <shlobj.h>
79 #include <shlwapi.h>
80 #include <io.h>
81 #include <process.h>
82 #include <malloc.h>
83 #else
84 #include <sys/time.h>
85 #include <sys/resource.h>
86 #include <sys/socket.h>
(77 . 7)(51 . 7)
88 #include <ifaddrs.h>
89 #include <fcntl.h>
90 #include <signal.h>
91 #endif
92
93 #ifdef BSD
94 #include <netinet/in.h>
95 #endif
- 44DF7FD78D25997FD3E84E4DF43EA6511DE2AED69DCED33A64A14D9C918CA34EEA4D5FD1AFFF711B490991CE90F90CF67052433CDD5FCCDA08BB974E75F0929D
+ A8B85AA6DBA112F0E314BD86F737D2FEF1206E4AD81B4C346C053D2BF3E4F36A1F5687DCD1321A0A7F3884DB1FB31FFCE69603AFB78F7C4E1B5CA638840A4404
bitcoin/src/init.cpp
(25 . 10)(25 . 6)
100
101 void ExitTimeout(void* parg)
102 {
103 #ifdef WIN32
104 Sleep(5000);
105 ExitProcess(0);
106 #endif
107 }
108
109 void Shutdown(void* parg)
(113 . 19)(109 . 8)
111
112 bool AppInit2(int argc, char* argv[])
113 {
114 #ifdef _MSC_VER
115 // Turn off microsoft heap dump noise
116 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
117 _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
118 #endif
119 #if _MSC_VER >= 1400
120 // Disable confusing "helpful" text message on abort, ctrl-c
121 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
122 #endif
123 #ifndef WIN32
124 umask(077);
125 #endif
126 #ifndef WIN32
127
128 // Clean shutdown on SIGTERM
129 struct sigaction sa;
130 sa.sa_handler = HandleSIGTERM;
(134 . 7)(119 . 6)
132 sigaction(SIGTERM, &sa, NULL);
133 sigaction(SIGINT, &sa, NULL);
134 sigaction(SIGHUP, &sa, NULL);
135 #endif
136
137 //
138 // Parameters
(189 . 16)(173 . 11)
140 " -maxreceivebuffer=<n>\t " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)\n") +
141 " -maxsendbuffer=<n>\t " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)\n") +
142 " -paytxfee=<amt> \t " + _("Fee per kB to add to transactions you send\n") +
143 #if !defined(WIN32)
144 " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") +
145 #endif
146 " -testnet \t\t " + _("Use the test network\n") +
147 " -debug \t\t " + _("Output extra debugging information\n") +
148 " -logtimestamps \t " + _("Prepend debug output with timestamp\n") +
149 " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") +
150 #ifdef WIN32
151 " -printtodebugger \t " + _("Send trace/debug info to debugger\n") +
152 #endif
153 " -rpcuser=<user> \t " + _("Username for JSON-RPC connections\n") +
154 " -rpcpassword=<pw>\t " + _("Password for JSON-RPC connections\n") +
155 " -rpcport=<port> \t\t " + _("Listen for JSON-RPC connections on <port> (default: 8332)\n") +
(218 . 12)(197 . 7)
157
158 fTestNet = GetBoolArg("-testnet");
159 fDebug = GetBoolArg("-debug");
160
161 #if !defined(WIN32)
162 fDaemon = GetBoolArg("-daemon");
163 #else
164 fDaemon = false;
165 #endif
166
167 if (fDaemon)
168 fServer = true;
(246 . 7)(220 . 6)
170 exit(ret);
171 }
172
173 #if !defined(WIN32)
174 if (fDaemon)
175 {
176 // Daemonize
(266 . 7)(239 . 6)
178 if (sid < 0)
179 fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
180 }
181 #endif
182
183 if (!fDebug && !pszSetDataDir[0])
184 ShrinkDebugFile();
- 784C9AF0366EE1F7033155638503BC35FF23AAF675E177F3917F0890E14A9D5CEEB80FD833751D674F0D7E41E6FE1D93EA32694872028FEC1DC8A83C0AD17944
+ 8CFDDA6FD46E07E50AB42E4F4652274C324B6020F30A340B6BB9EE3FD620C497473C8480102218D48261646D7ADFECFF7FF987F8A798997B4D3EBD032066D78D
bitcoin/src/main.h
(923 . 11)(923 . 7)
189 fflush(fileout);
190 if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0)
191 {
192 #ifdef WIN32
193 _commit(_fileno(fileout));
194 #else
195 fsync(fileno(fileout));
196 #endif
197 }
198
199 return true;
- C345F6B5BC7D336782F8C032D9FC7BA0004A64782F1373DC82E3B117DC276A10C0BD0E31B646D8E9BBB4FFB6A9E6878A0D17851AF9748B93B0107F3B4285A5A0
+
bitcoin/src/makefile.linux-mingw
(1 . 95)(0 . 0)
204 # Copyright (c) 2009-2010 Satoshi Nakamoto
205 # Distributed under the MIT/X11 software license, see the accompanying
206 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
207
208 DEPSDIR:=/usr/i586-mingw32msvc
209
210 INCLUDEPATHS= \
211 -I"$(DEPSDIR)/boost_1_47_0" \
212 -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
213 -I"$(DEPSDIR)/openssl-1.0.0e/include" \
214 -I"$(DEPSDIR)"
215
216 LIBPATHS= \
217 -L"$(DEPSDIR)/boost_1_47_0/stage/lib" \
218 -L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
219 -L"$(DEPSDIR)/openssl-1.0.0e"
220
221 LIBS= \
222 -l boost_system-mt-s \
223 -l boost_filesystem-mt-s \
224 -l boost_program_options-mt-s \
225 -l boost_thread_win32-mt-s \
226 -l db_cxx \
227 -l ssl \
228 -l crypto
229
230 DEFS=-D_MT -DWIN32 -D_WINDOWS -DNOPCH -DBOOST_THREAD_USE_LIB
231 DEBUGFLAGS=-g
232 CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
233 HEADERS = \
234 base58.h \
235 bignum.h \
236 checkpoints.h \
237 crypter.h \
238 db.h \
239 headers.h \
240 init.h \
241 irc.h \
242 key.h \
243 keystore.h \
244 main.h \
245 net.h \
246 noui.h \
247 protocol.h \
248 bitcoinrpc.h \
249 script.h \
250 serialize.h \
251 strlcpy.h \
252 uint256.h \
253 util.h \
254 wallet.h
255
256
257
258 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
259
260 OBJS= \
261 obj/checkpoints.o \
262 obj/crypter.o \
263 obj/db.o \
264 obj/init.o \
265 obj/irc.o \
266 obj/keystore.o \
267 obj/main.o \
268 obj/net.o \
269 obj/protocol.o \
270 obj/bitcoinrpc.o \
271 obj/script.o \
272 obj/util.o \
273 obj/wallet.o
274
275 all: bitcoind.exe
276
277 obj/nogui/%.o: %.cpp $(HEADERS)
278 i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
279
280 bitcoind.exe: $(OBJS:obj/%=obj/nogui/%)
281 i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
282
283
284 obj/test/%.o: obj/test/%.cpp $(HEADERS)
285 i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $<
286
287 test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
288 i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s
289
290
291 clean:
292 -rm -f obj/*.o
293 -rm -f obj/nogui/*.o
294 -rm -f obj/test/*.o
295 -rm -f test/*.o
296 -rm -f headers.h.gch
297 -rm -f bitcoind.exe
298 -rm -f test_bitcoin.exe
- 50F2BF26C02D6EDBD0AEC5A3E5B3DDCEAFFAB27C16D51A4DD972E42E01871D8E34314F525E9394211801C9EA7D1BD8F8266AE214B30A8E645CE207BF5F3BBD92
+ C67FDD55E9D9D6B4973122B76729D7E83A456A8DC410F1C130CFFBFD9F626C47CA7E8006BDE912D9E0BD0A4B8457E895270D4A0EFD22C4A199CD52FFD95B10DD
bitcoin/src/net.cpp
(10 . 10)(10 . 6)
303 #include "init.h"
304 #include "strlcpy.h"
305
306 #ifdef WIN32
307 #include <string.h>
308 #endif
309
310
311 using namespace std;
312 using namespace boost;
(94 . 13)(90 . 9)
314 bool fProxy = (fUseProxy && addrConnect.IsRoutable());
315 struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr());
316
317 #ifdef WIN32
318 u_long fNonblock = 1;
319 if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
320 #else
321 int fFlags = fcntl(hSocket, F_GETFL, 0);
322 if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == -1)
323 #endif
324
325 {
326 closesocket(hSocket);
327 return false;
(133 . 11)(125 . 7)
329 return false;
330 }
331 socklen_t nRetSize = sizeof(nRet);
332 #ifdef WIN32
333 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR)
334 #else
335 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR)
336 #endif
337 {
338 printf("getsockopt() for connection failed: %i\n",WSAGetLastError());
339 closesocket(hSocket);
(150 . 11)(138 . 7)
341 return false;
342 }
343 }
344 #ifdef WIN32
345 else if (WSAGetLastError() != WSAEISCONN)
346 #else
347 else
348 #endif
349 {
350 printf("connect() failed: %i\n",WSAGetLastError());
351 closesocket(hSocket);
(167 . 13)(151 . 8)
353 CNode::ConnectNode immediately turns the socket back to non-blocking
354 but we'll turn it back to blocking just in case
355 */
356 #ifdef WIN32
357 fNonblock = 0;
358 if (ioctlsocket(hSocket, FIONBIO, &fNonblock) == SOCKET_ERROR)
359 #else
360 fFlags = fcntl(hSocket, F_GETFL, 0);
361 if (fcntl(hSocket, F_SETFL, fFlags & !O_NONBLOCK) == SOCKET_ERROR)
362 #endif
363 {
364 closesocket(hSocket);
365 return false;
(670 . 14)(649 . 8)
367 printf("connected %s\n", addrConnect.ToString().c_str());
368
369 // Set to nonblocking
370 #ifdef WIN32
371 u_long nOne = 1;
372 if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR)
373 printf("ConnectSocket() : ioctlsocket nonblocking setting failed, error %d\n", WSAGetLastError());
374 #else
375 if (fcntl(hSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
376 printf("ConnectSocket() : fcntl nonblocking setting failed, error %d\n", errno);
377 #endif
378
379 // Add node
380 CNode* pnode = new CNode(hSocket, addrConnect, false);
(1564 . 18)(1537 . 6)
382 int nOne = 1;
383 addrLocalHost.port = htons(GetListenPort());
384
385 #ifdef WIN32
386 // Initialize Windows Sockets
387 WSADATA wsadata;
388 int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
389 if (ret != NO_ERROR)
390 {
391 strError = strprintf("Error: TCP/IP socket library failed to start (WSAStartup returned error %d)", ret);
392 printf("%s\n", strError.c_str());
393 return false;
394 }
395 #endif
396
397 // Create socket for listening for incoming connections
398 hListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
399 if (hListenSocket == INVALID_SOCKET)
(1590 . 18)(1551 . 11)
401 setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int));
402 #endif
403
404 #ifndef WIN32
405 // Allow binding if the port is still in TIME_WAIT state after
406 // the program was closed and restarted. Not an issue on windows.
407 setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int));
408 #endif
409
410 #ifdef WIN32
411 // Set to nonblocking, incoming connections will also inherit this
412 if (ioctlsocket(hListenSocket, FIONBIO, (u_long*)&nOne) == SOCKET_ERROR)
413 #else
414 if (fcntl(hListenSocket, F_SETFL, O_NONBLOCK) == SOCKET_ERROR)
415 #endif
416 {
417 strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %d)", WSAGetLastError());
418 printf("%s\n", strError.c_str());
(1643 . 21)(1597 . 6)
420 if (pnodeLocalHost == NULL)
421 pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress("127.0.0.1", 0, false, nLocalServices));
422
423 #ifdef WIN32
424 // Get local host ip
425 char pszHostName[1000] = "";
426 if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
427 {
428 vector<CAddress> vaddr;
429 if (Lookup(pszHostName, vaddr, nLocalServices, -1, true))
430 BOOST_FOREACH (const CAddress &addr, vaddr)
431 if (addr.GetByte(3) != 127)
432 {
433 addrLocalHost = addr;
434 break;
435 }
436 }
437 #else
438 // Get local host ip
439 struct ifaddrs* myaddrs;
440 if (getifaddrs(&myaddrs) == 0)
(1692 . 7)(1631 . 7)
442 }
443 freeifaddrs(myaddrs);
444 }
445 #endif
446
447 printf("addrLocalHost = %s\n", addrLocalHost.ToString().c_str());
448
449 if (fUseProxy || mapArgs.count("-connect") || fNoListen)
(1778 . 10)(1717 . 6)
451 if (closesocket(hListenSocket) == SOCKET_ERROR)
452 printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
453
454 #ifdef WIN32
455 // Shutdown Windows Sockets
456 WSACleanup();
457 #endif
458 }
459 }
460 instance_of_cnetcleanup;
- AE473B8D2838555DF527E16AC7CAE7DFFF39BFD68769B1FCABB1F847E29E1245AF78799942E790016C376A76E112B9EC16D2D7D5F52736E3CC72E45432706D3B
+ 08231AA424AE8C84086B5B82EA79A7F22FB3403B4245C6D05A20176C4962AE620A35B9CB2505F4B8E33A8F43D077152406007013E49E97AB1CEED6B158B77A0F
bitcoin/src/net.h
(10 . 10)(10 . 6)
465 #include <boost/foreach.hpp>
466 #include <openssl/rand.h>
467
468 #ifndef WIN32
469 #include <arpa/inet.h>
470 #endif
471
472 #include "protocol.h"
473
474 class CAddrDB;
- 09C7F4CC1247B2EC45FFDAE139FE2574DAE0EB4CD40D0E48CFD5DE49033AB1F4242E564020E4AF5418B12E7A78430C87D58B1D4829C837B9DAE47D1C1CD32382
+ 8FAEDDC8CA1B84E53EDEE8F3325EDD7DB8B74E063F4D338AE7E280C02DCE96E8156157A6802FEAB5B7F695981E6F8A42AB5F44B9DF3093A4D7C4F30F9B029912
bitcoin/src/protocol.cpp
(5 . 10)(5 . 8)
479
480 #include "protocol.h"
481 #include "util.h"
482 #include <arpa/inet.h>
483
484 #ifndef WIN32
485 # include <arpa/inet.h>
486 #endif
487
488 // Prototypes from net.h, but that header (currently) stinks, can't #include it without breaking things
489 bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false);
(165 . 11)(163 . 7)
491 ss.reserve(18);
492 ss << FLATDATA(pchReserved) << ip << port;
493
494 #if defined(_MSC_VER) && _MSC_VER < 1300
495 return std::vector<unsigned char>((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]);
496 #else
497 return std::vector<unsigned char>(ss.begin(), ss.end());
498 #endif
499 }
500
501 struct sockaddr_in CAddress::GetSockAddr() const
- 72636DBD07E5917231EE2B62473BE7A766E0E62E573315CC48E38B524DA2885803B024F0613FA52C347BA0ED19455CA9461E980018E66D5CA9B05CE0BC380693
+ 796B2AB92A49E29B5873BE0D63D732D1B973855DE76062492190687C57FDBEFC069091DF6306A0EEE86AD5717C8FA90774EA9B8589CBA2D9138B544C37E7177F
bitcoin/src/script.h
(384 . 9)(384 . 7)
506 CScript() { }
507 CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
508 CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }
509 #ifndef _MSC_VER
510 CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }
511 #endif
512
513 CScript& operator+=(const CScript& b)
514 {
- 0DCF98014ABE06B33AB296A747E42E88770A87F8D4E408BE4FC1EBE6B02312695CC129D0B58C0886BF8521B6D2C79BF6F2C33E19C03AEE8F5357D8DB779829AD
+ 762E48EEAE1D5086A18FC1F37DFC395CA6A6C393AA71DC177E19C106E69B3E3E3130252EC7D229976D1BCB325A1E6BD1CA5E73DE1EBBA6C37D71326385A4244C
bitcoin/src/serialize.h
(19 . 27)(19 . 9)
519 #include <boost/tuple/tuple_comparison.hpp>
520 #include <boost/tuple/tuple_io.hpp>
521
522 #if defined(_MSC_VER) || defined(__BORLANDC__)
523 typedef __int64 int64;
524 typedef unsigned __int64 uint64;
525 #else
526 typedef long long int64;
527 typedef unsigned long long uint64;
528 #endif
529 #if defined(_MSC_VER) && _MSC_VER < 1300
530 #define for if (false) ; else for
531 #endif
532
533 #ifdef WIN32
534 #include <windows.h>
535 // This is used to attempt to keep keying material out of swap
536 // Note that VirtualLock does not provide this as a guarantee on Windows,
537 // but, in practice, memory that has been VirtualLock'd almost never gets written to
538 // the pagefile except in rare circumstances where memory is extremely low.
539 #include <windows.h>
540 #define mlock(p, n) VirtualLock((p), (n));
541 #define munlock(p, n) VirtualUnlock((p), (n));
542 #else
543 #include <sys/mman.h>
544 #include <limits.h>
545 /* This comes from limits.h if it's not defined there set a sane default */
(53 . 7)(35 . 6)
547 #define munlock(a,b) \
548 munlock(((void *)(((size_t)(a)) & (~((PAGESIZE)-1)))),\
549 (((((size_t)(a)) + (b) - 1) | ((PAGESIZE) - 1)) + 1) - (((size_t)(a)) & (~((PAGESIZE) - 1))))
550 #endif
551
552 class CScript;
553 class CDataStream;
(902 . 12)(883 . 10)
555 Init(nTypeIn, nVersionIn);
556 }
557
558 #if !defined(_MSC_VER) || _MSC_VER >= 1300
559 CDataStream(const char* pbegin, const char* pend, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(pbegin, pend)
560 {
561 Init(nTypeIn, nVersionIn);
562 }
563 #endif
564
565 CDataStream(const vector_type& vchIn, int nTypeIn=SER_NETWORK, int nVersionIn=VERSION) : vch(vchIn.begin(), vchIn.end())
566 {
(993 . 7)(972 . 6)
568 vch.insert(it, first, last);
569 }
570
571 #if !defined(_MSC_VER) || _MSC_VER >= 1300
572 void insert(iterator it, const char* first, const char* last)
573 {
574 if (it == vch.begin() + nReadPos && last - first <= nReadPos)
(1005 . 7)(983 . 6)
576 else
577 vch.insert(it, first, last);
578 }
579 #endif
580
581 iterator erase(iterator it)
582 {
- 3436729B55463EBB34788A47A8856D47BA7EBC27F447C5FF73B8727897D7C468716D8313E9B613E7889A7C3DFFA6E577D77149AE8C4C415FB41CE3FC5CC6D852
+ BFF76A65E51957209D7753535337D23927A9A1ACC829C5BC5D9F266A1B8C004B555DAAE74E75B616CA0088F8BE0739F082D64EDC2387495B3675BEBD25658FD3
bitcoin/src/uint256.h
(11 . 17)(11 . 8)
587 #include <string>
588 #include <vector>
589
590 #if defined(_MSC_VER) || defined(__BORLANDC__)
591 typedef __int64 int64;
592 typedef unsigned __int64 uint64;
593 #else
594 typedef long long int64;
595 typedef unsigned long long uint64;
596 #endif
597 #if defined(_MSC_VER) && _MSC_VER < 1300
598 #define for if (false) ; else for
599 #endif
600
601
602 inline int Testuint256AdHoc(std::vector<std::string> vArg);
603
- 4B0F7B3A7757336B6E5C349D89170BFC4B4C40A04E0EC3FCCF0B155314689C781DEB9590AB05DAA8AF20A123E2F3CAD55C5AF1244700197A3530D0D4699D32C5
+ 626E2306C3784911C960136E39BD3EB7C925CA90378FAA03FB616A5D7180335889F0807BB39C9AC1907B285C43E730558190E1A1D5717EBA4BAE6006A9ABEDFD
bitcoin/src/util.cpp
(64 . 11)(64 . 6)
608 ppmutexOpenSSL[i] = new boost::interprocess::interprocess_mutex();
609 CRYPTO_set_locking_callback(locking_callback);
610
611 #ifdef WIN32
612 // Seed random number generator with screen scrape and other hardware sources
613 RAND_screen();
614 #endif
615
616 // Seed random number generator with performance counter
617 RandAddSeed();
618 }
(108 . 21)(103 . 6)
620 return;
621 nLastPerfmon = GetTime();
622
623 #ifdef WIN32
624 // Don't need this on Linux, OpenSSL automatically uses /dev/urandom
625 // Seed with the entire set of perfmon data
626 unsigned char pdata[250000];
627 memset(pdata, 0, sizeof(pdata));
628 unsigned long nSize = sizeof(pdata);
629 long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);
630 RegCloseKey(HKEY_PERFORMANCE_DATA);
631 if (ret == ERROR_SUCCESS)
632 {
633 RAND_add(pdata, nSize, nSize/100.0);
634 memset(pdata, 0, nSize);
635 printf("%s RandAddSeed() %d bytes\n", DateTimeStrFormat("%x %H:%M", GetTime()).c_str(), nSize);
636 }
637 #endif
638 }
639
640 uint64 GetRand(uint64 nMax)
(198 . 48)(178 . 6)
642 }
643 }
644
645 #ifdef WIN32
646 if (fPrintToDebugger)
647 {
648 static CCriticalSection cs_OutputDebugStringF;
649
650 // accumulate a line at a time
651 CRITICAL_BLOCK(cs_OutputDebugStringF)
652 {
653 static char pszBuffer[50000];
654 static char* pend;
655 if (pend == NULL)
656 pend = pszBuffer;
657 va_list arg_ptr;
658 va_start(arg_ptr, pszFormat);
659 int limit = END(pszBuffer) - pend - 2;
660 int ret = _vsnprintf(pend, limit, pszFormat, arg_ptr);
661 va_end(arg_ptr);
662 if (ret < 0 || ret >= limit)
663 {
664 pend = END(pszBuffer) - 2;
665 *pend++ = '\n';
666 }
667 else
668 pend += ret;
669 *pend = '\0';
670 char* p1 = pszBuffer;
671 char* p2;
672 while (p2 = strchr(p1, '\n'))
673 {
674 p2++;
675 char c = *p2;
676 *p2 = '\0';
677 OutputDebugStringA(p1);
678 *p2 = c;
679 p1 = p2;
680 }
681 if (p1 != pszBuffer)
682 memmove(pszBuffer, p1, pend - p1 + 1);
683 pend -= (p1 - pszBuffer);
684 }
685 }
686 #endif
687 return ret;
688 }
689
(457 . 11)(395 . 6)
691 pszValue = strchr(psz, '=');
692 *pszValue++ = '\0';
693 }
694 #ifdef WIN32
695 _strlwr(psz);
696 if (psz[0] == '/')
697 psz[0] = '-';
698 #endif
699 if (psz[0] != '-')
700 break;
701 mapArgs[psz] = pszValue;
(665 . 13)(598 . 7)
703
704 void FormatException(char* pszMessage, std::exception* pex, const char* pszThread)
705 {
706 #ifdef WIN32
707 char pszModule[MAX_PATH];
708 pszModule[0] = '\0';
709 GetModuleFileNameA(NULL, pszModule, sizeof(pszModule));
710 #else
711 const char* pszModule = "bitcoin";
712 #endif
713 if (pex)
714 snprintf(pszMessage, 1000,
715 "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread);
(717 . 67)(644 . 10)
717 strMiscWarning = pszMessage;
718 }
719
720
721
722
723
724
725
726
727 #ifdef WIN32
728 typedef WINSHELLAPI BOOL (WINAPI *PSHGETSPECIALFOLDERPATHA)(HWND hwndOwner, LPSTR lpszPath, int nFolder, BOOL fCreate);
729
730 string MyGetSpecialFolderPath(int nFolder, bool fCreate)
731 {
732 char pszPath[MAX_PATH+100] = "";
733
734 // SHGetSpecialFolderPath isn't always available on old Windows versions
735 HMODULE hShell32 = LoadLibraryA("shell32.dll");
736 if (hShell32)
737 {
738 PSHGETSPECIALFOLDERPATHA pSHGetSpecialFolderPath =
739 (PSHGETSPECIALFOLDERPATHA)GetProcAddress(hShell32, "SHGetSpecialFolderPathA");
740 bool fSuccess = false;
741 if (pSHGetSpecialFolderPath)
742 fSuccess =
743 (*pSHGetSpecialFolderPath)(NULL, pszPath, nFolder, fCreate);
744 FreeModule(hShell32);
745 if (fSuccess)
746 return pszPath;
747 }
748
749 // Backup option
750 std::string strPath;
751 {
752 const char *pszEnv;
753 if (nFolder == CSIDL_STARTUP)
754 {
755 pszEnv = getenv("USERPROFILE");
756 if (pszEnv)
757 strPath = pszEnv;
758 strPath += "\\Start Menu\\Programs\\Startup";
759 }
760 else if (nFolder == CSIDL_APPDATA)
761 {
762 pszEnv = getenv("APPDATA");
763 if (pszEnv)
764 strPath = pszEnv;
765 }
766 }
767
768 return strPath;
769 }
770 #endif
771
772 string GetDefaultDataDir()
773 {
774 // Windows: C:\Documents and Settings\username\Application Data\Bitcoin
775 // Mac: ~/Library/Application Support/Bitcoin
776 // Unix: ~/.bitcoin
777 #ifdef WIN32
778 // Windows
779 return MyGetSpecialFolderPath(CSIDL_APPDATA, true) + "\\Bitcoin";
780 #else
781 char* pszHome = getenv("HOME");
782 if (pszHome == NULL || strlen(pszHome) == 0)
783 pszHome = (char*)"/";
(793 . 7)(663 . 6)
785 // Unix
786 return strHome + ".bitcoin";
787 #endif
788 #endif
789 }
790
791 void GetDataDir(char* pszDir)
- 1355AD6CE93816FFFC1BEFD7A68A5FBDF034AE24AE99C64A60269CA9DB589363D6531F441CD2393630E3128C2762DDCB8101DD6C305551B70CF24E102E59CFD0
+ 1E2275FEA3780708AED4D4C7DE351B23A9379354DF29DDA39B8BF2CCC72DF95713514B2B7837DC2230D42CF8234744E804BFD608FB4442FF62871257F8D80C12
bitcoin/src/util.h
(7 . 11)(7 . 10)
796
797 #include "uint256.h"
798
799 #ifndef WIN32
800
801 #include <sys/types.h>
802 #include <sys/time.h>
803 #include <sys/resource.h>
804 #endif
805 #include <map>
806 #include <vector>
807 #include <string>
(25 . 19)(24 . 10)
809 #include <openssl/ripemd.h>
810
811
812 #if defined(_MSC_VER) || defined(__BORLANDC__)
813 typedef __int64 int64;
814 typedef unsigned __int64 uint64;
815 #else
816 typedef long long int64;
817 typedef unsigned long long uint64;
818 #endif
819 #if defined(_MSC_VER) && _MSC_VER < 1300
820 #define for if (false) ; else for
821 #endif
822 #ifndef _MSC_VER
823
824 #define __forceinline inline
825 #endif
826
827 #define loop for (;;)
828 #define BEGIN(a) ((char*)&(a))
(53 . 16)(43 . 10)
830 #define snprintf my_snprintf
831
832 #ifndef PRI64d
833 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MSVCRT__)
834 #define PRI64d "I64d"
835 #define PRI64u "I64u"
836 #define PRI64x "I64x"
837 #else
838 #define PRI64d "lld"
839 #define PRI64u "llu"
840 #define PRI64x "llx"
841 #endif
842 #endif
843
844 // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
845 #define PAIRTYPE(t1, t2) std::pair<t1, t2>
(81 . 21)(65 . 6)
847 return u.ptr;
848 }
849
850 #ifdef WIN32
851 #define MSG_NOSIGNAL 0
852 #define MSG_DONTWAIT 0
853 #ifndef UINT64_MAX
854 #define UINT64_MAX _UI64_MAX
855 #define INT64_MAX _I64_MAX
856 #define INT64_MIN _I64_MIN
857 #endif
858 #ifndef S_IRUSR
859 #define S_IRUSR 0400
860 #define S_IWUSR 0200
861 #endif
862 #define unlink _unlink
863 typedef int socklen_t;
864 #else
865 #define WSAGetLastError() errno
866 #define WSAEINVAL EINVAL
867 #define WSAEALREADY EALREADY
(119 . 17)(88 . 13)
869 So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/
870 boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n));
871 }
872 #endif
873
874
875 inline int myclosesocket(SOCKET& hSocket)
876 {
877 if (hSocket == INVALID_SOCKET)
878 return WSAENOTSOCK;
879 #ifdef WIN32
880 int ret = closesocket(hSocket);
881 #else
882 int ret = close(hSocket);
883 #endif
884 hSocket = INVALID_SOCKET;
885 return ret;
886 }
(140 . 14)(105 . 6)
888 }
889
890
891
892
893
894
895
896
897
898
899 extern std::map<std::string, std::string> mapArgs;
900 extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
901 extern bool fDebug;
(193 . 9)(150 . 6)
903 std::string GetPidFile();
904 void CreatePidFile(std::string pidFile, pid_t pid);
905 void ReadConfigFile(std::map<std::string, std::string>& mapSettingsRet, std::map<std::string, std::vector<std::string> >& mapMultiSettingsRet);
906 #ifdef WIN32
907 std::string MyGetSpecialFolderPath(int nFolder, bool fCreate);
908 #endif
909 std::string GetDefaultDataDir();
910 std::string GetDataDir();
911 void ShrinkDebugFile();
(323 . 20)(277 . 12)
913
914 inline int64 atoi64(const char* psz)
915 {
916 #ifdef _MSC_VER
917 return _atoi64(psz);
918 #else
919 return strtoll(psz, NULL, 10);
920 #endif
921 }
922
923 inline int64 atoi64(const std::string& str)
924 {
925 #ifdef _MSC_VER
926 return _atoi64(str.c_str());
927 #else
928 return strtoll(str.c_str(), NULL, 10);
929 #endif
930 }
931
932 inline int atoi(const std::string& str)
(411 . 13)(357 . 9)
934 inline int64 GetPerformanceCounter()
935 {
936 int64 nCounter = 0;
937 #ifdef WIN32
938 QueryPerformanceCounter((LARGE_INTEGER*)&nCounter);
939 #else
940 timeval t;
941 gettimeofday(&t, NULL);
942 nCounter = t.tv_sec * 1000000 + t.tv_usec;
943 #endif
944 return nCounter;
945 }
946
(445 . 11)(387 . 7)
948
949 inline bool IsSwitchChar(char c)
950 {
951 #ifdef WIN32
952 return c == '-' || c == '/';
953 #else
954 return c == '-';
955 #endif
956 }
957
958 inline std::string GetArg(const std::string& strArg, const std::string& strDefault)
(505 . 11)(443 . 6)
960
961 inline void heapchk()
962 {
963 #ifdef WIN32
964 /// for debugging
965 //if (_heapchk() != _HEAPOK)
966 // DebugBreak();
967 #endif
968 }
969
970 // Randomize the stack to help protect against buffer overrun exploits
(664 . 38)(597 . 6)
972
973 // Note: It turns out we might have been able to use boost::thread
974 // by using TerminateThread(boost::thread.native_handle(), 0);
975 #ifdef WIN32
976 typedef HANDLE pthread_t;
977
978 inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
979 {
980 DWORD nUnused = 0;
981 HANDLE hthread =
982 CreateThread(
983 NULL, // default security
984 0, // inherit stack size from parent
985 (LPTHREAD_START_ROUTINE)pfn, // function pointer
986 parg, // argument
987 0, // creation option, start immediately
988 &nUnused); // thread identifier
989 if (hthread == NULL)
990 {
991 printf("Error: CreateThread() returned %d\n", GetLastError());
992 return (pthread_t)0;
993 }
994 if (!fWantHandle)
995 {
996 CloseHandle(hthread);
997 return (pthread_t)-1;
998 }
999 return hthread;
1000 }
1001
1002 inline void SetThreadPriority(int nPriority)
1003 {
1004 SetThreadPriority(GetCurrentThread(), nPriority);
1005 }
1006 #else
1007 inline pthread_t CreateThread(void(*pfn)(void*), void* parg, bool fWantHandle=false)
1008 {
1009 pthread_t hthread = 0;
(738 . 29)(639 . 11)
1011 {
1012 pthread_exit((void*)nExitCode);
1013 }
1014 #endif
1015
1016
1017
1018
1019
1020 inline bool AffinityBugWorkaround(void(*pfn)(void*))
1021 {
1022 #ifdef WIN32
1023 // Sometimes after a few hours affinity gets stuck on one processor
1024 DWORD_PTR dwProcessAffinityMask = -1;
1025 DWORD_PTR dwSystemAffinityMask = -1;
1026 GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask);
1027 DWORD dwPrev1 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
1028 DWORD dwPrev2 = SetThreadAffinityMask(GetCurrentThread(), dwProcessAffinityMask);
1029 if (dwPrev2 != dwProcessAffinityMask)
1030 {
1031 printf("AffinityBugWorkaround() : SetThreadAffinityMask=%d, ProcessAffinityMask=%d, restarting thread\n", dwPrev2, dwProcessAffinityMask);
1032 if (!CreateThread(pfn, NULL))
1033 printf("Error: CreateThread() failed\n");
1034 return true;
1035 }
1036 #endif
1037 return false;
1038 }
1039