changeset 441:0d6cf2dc0aa7 draft

Merge branch 'master' of https://github.com/sandos/bitcoin into sandos-master
author tcatm <tcatm@gawab.com>
date Wed, 23 Feb 2011 01:07:43 +0100
parents 79faf1c282c2 (diff) 10b5ecf3f7e9 (current diff)
children 9a28208901e8
files rpc.cpp
diffstat 8 files changed, 122 insertions(+), 128 deletions(-) [+]
line wrap: on
line diff
--- a/build-msw.txt
+++ b/build-msw.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2009-2010 Satoshi Nakamoto
+Copyright (c) 2009-2011 Bitcoin Developers
 Distributed under the MIT/X11 software license, see the accompanying
 file license.txt or http://www.opensource.org/licenses/mit-license.php.
 This product includes software developed by the OpenSSL Project for use in
@@ -11,23 +11,25 @@
 
 Compilers Supported
 -------------------
-MinGW GCC (recommended)
-http://tdm-gcc.tdragon.net/ has an easy installer.  Go back a few versions
-for a little older gcc like gcc 4.4.?.
+MinGW GCC  http://tdm-gcc.tdragon.net/
+   TDM-GCC with gcc 4.5.1 was used to build this release.
+MSYS 1.0.11 was also used (sh needed to compile some dependencies)
 
-MSVC 8.0 (2005) SP1 has been tested.  Note: MSVC 7.0 and up have a habit of
-linking to runtime DLLs that are not installed on XP by default.
+
+Candidate releases were built with MSVC 10.0 (2010), but
+compiling with Visual C++ caused rendering artifacts when
+bitcoin was run.
 
 
 Dependencies
 ------------
 Libraries you need to download separately and build:
 
-             default path  download
-wxWidgets-2.9  \wxwidgets   http://www.wxwidgets.org/downloads/
-OpenSSL        \openssl     http://www.openssl.org/source/
-Berkeley DB    \db          http://www.oracle.com/technology/software/products/berkeley-db/index.html
-Boost          \boost       http://www.boost.org/users/download/
+                default path  download
+wxWidgets       \wxwidgets-2.9.1-mgw   http://www.wxwidgets.org/downloads/
+OpenSSL         \openssl-1.0.0c-mgw    http://www.openssl.org/source/
+Berkeley DB     \db-4.7.25.NC-mgw      http://www.oracle.com/technology/software/products/berkeley-db/index.html
+Boost           \boost-1.43.0-mgw      http://www.boost.org/users/download/
 
 Their licenses:
 wxWidgets      LGPL 2.1 with very liberal exceptions
@@ -36,11 +38,10 @@
 Boost          MIT-like license
 
 Versions used in this release:
-MinGW GCC    3.4.5
-wxWidgets    2.9.0
-OpenSSL      0.9.8k
+wxWidgets    2.9.1
+OpenSSL      1.0.0c
 Berkeley DB  4.7.25.NC
-Boost        1.42.1
+Boost        1.43.0
 
 
 Notes
@@ -49,61 +50,50 @@
 uiproject.fbp.  It generates uibase.cpp and uibase.h, which define base
 classes that do the rote work of constructing all the UI elements.
 
-The release is built with GCC and then "strip bitcoin.exe" to strip the debug
-symbols, which reduces the executable size by about 90%.
-
-
 wxWidgets
 ---------
-cd \wxwidgets\build\msw
-make -f makefile.gcc
- or
-nmake -f makefile.vc
-
+DOS shell:
+cd \wxWidgets-2.9.1-mgw\build\msw
+mingw32-make -f makefile.gcc
 
 OpenSSL
 -------
-If you want to exclude unused optional algorithms, a few patches are required.
-(instructions for OpenSSL v0.9.8k)
-
-Edit engines\e_gmp.c and engines\e_capi.c and add this #ifndef around
-the openssl/rsa.h include:
-  #ifndef OPENSSL_NO_RSA
-  #include <openssl/rsa.h>
-  #endif
-
-Edit ms\mingw32.bat and replace the Configure line's parameters with this
-no-everything list.  You have to put this in the batch file because batch
-files can't take more than nine command line parameters.
-  perl Configure mingw threads no-rc2 no-rc4 no-rc5 no-idea no-des no-bf no-cast no-aes no-camellia no-seed no-rsa no-dh
+MSYS shell:
+un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)
+change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'
 
-Also REM out the following line in ms\mingw32.bat after the mingw32-make
-line.  The build fails after it's already finished building libeay32, which
-is all we care about, but the failure aborts the script before it runs
-dllwrap to generate libeay32.dll.
-  REM  if errorlevel 1 goto end
+cd /c/openssl-1.0.0c-mgw
+./config
+make
 
-Build
-  cd \openssl
-  ms\mingw32.bat
+perl util/mkdef.pl 32 libeay enable-static-engine > libeay32.def
+dllwrap --dllname libeay32.dll --output-lib libeay32.a --def libeay32.def libcrypto.a -lws2_32 -lgdi32
 
-If you're using MSVC, generate the .lib file
-  lib /machine:i386 /def:ms\libeay32.def /out:out\libeay32.lib
-
+after that openssl libeay is in main source dir (openssl-1.0.0c-mgw)
 
 Berkeley DB
 -----------
-Using MinGW and MSYS:
-cd \db\build_unix
+MSYS shell:
+cd /c/db-4.7.25.NC-mgw/build_unix
 sh ../dist/configure --enable-mingw --enable-cxx
 make
 
 
 Boost
 -----
-download bjam.exe from
-http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941
-cd \boost
+DOS prompt:
+downloaded boost jam 3.1.18
+cd \boost-1.43.0-mgw
 bjam toolset=gcc --build-type=complete stage
- or
-bjam toolset=msvc --build-type=complete stage
+
+Note:
+building with boost 1.45.0 failed because of boost ticket 4614, 4258
+builds fine with boost 1.43.0
+
+Bitcoin
+-------
+DOS prompt:
+cd \bitcoin
+mingw32-make bitcoin.exe bitcoind.exe -f makefile.mingw
+strip bitcoin.exe
+strip bitcoind.exe
--- a/db.cpp
+++ b/db.cpp
@@ -843,7 +843,7 @@
         keyUser.MakeNewKey();
         if (!AddKey(keyUser))
             return false;
-        if (!SetAddressBookName(PubKeyToAddress(keyUser.GetPubKey()), "Your Address"))
+        if (!SetAddressBookName(PubKeyToAddress(keyUser.GetPubKey()), ""))
             return false;
         CWalletDB().WriteDefaultKey(keyUser.GetPubKey());
     }
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -4,26 +4,26 @@
 
 
 INCLUDEPATHS= \
- -I"/boost" \
- -I"/db/build_unix" \
- -I"/openssl/include" \
- -I"/wxwidgets/lib/gcc_lib/mswud" \
- -I"/wxwidgets/include"
+ -I"C:\boost-1.43.0-mgw" \
+ -I"C:\db-4.7.25.NC-mgw\build_unix" \
+ -I"C:\openssl-1.0.0c-mgw\include" \
+ -I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \
+ -I"C:\wxWidgets-2.9.1-mgw\include"
 
 LIBPATHS= \
- -L"/boost/stage/lib" \
- -L"/db/build_unix" \
- -L"/openssl/out" \
- -L"/wxwidgets/lib/gcc_lib"
+ -L"C:\boost-1.43.0-mgw\stage\lib" \
+ -L"C:\db-4.7.25.NC-mgw\build_unix" \
+ -L"C:\openssl-1.0.0c-mgw" \
+ -L"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib"
 
 WXLIBS= \
  -l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd
 
 LIBS= \
- -l libboost_system-mgw34-mt-d \
- -l libboost_filesystem-mgw34-mt-d \
- -l libboost_program_options-mgw34-mt-d \
- -l libboost_thread-mgw34-mt-d \
+ -l boost_system-mgw45-mt-s-1_43 \
+ -l boost_filesystem-mgw45-mt-s-1_43 \
+ -l boost_program_options-mgw45-mt-s-1_43 \
+ -l boost_thread-mgw45-mt-s-1_43 \
  -l db_cxx \
  -l eay32 \
  -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
--- a/makefile.vc
+++ b/makefile.vc
@@ -7,29 +7,32 @@
   /I"/boost" \
   /I"/db/build_windows" \
   /I"/openssl/include" \
-  /I"/wxwidgets/lib/vc_lib/mswud" \
+  /I"/wxwidgets/lib/vc_lib/mswu" \
   /I"/wxwidgets/include"
 
 LIBPATHS= \
   /LIBPATH:"/boost/stage/lib" \
-  /LIBPATH:"/db/build_windows/debug" \
-  /LIBPATH:"/openssl/out" \
-  /LIBPATH:"/wxwidgets/lib/vc_lib"
+  /LIBPATH:"/db/build_windows/Release" \
+  /LIBPATH:"/openssl/lib" \
+  /LIBPATH:"/wxwidgets/lib/vc_lib" \
+  /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib \
+  /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib \
+  /NODEFAULTLIB:msvcrtd.lib
 
-WXLIBS=wxmsw29ud_html.lib wxmsw29ud_core.lib wxmsw29ud_adv.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib
+WXLIBS=wxmsw29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib
 
 LIBS= \
-  libboost_system-vc80-mt-gd.lib \
-  libboost_filesystem-vc80-mt-gd.lib \
-  libboost_program_options-vc80-mt-gd.lib \
-  libboost_thread-vc80-mt-gd.lib \
-  libdb47sd.lib \
+  libboost_system-vc100-mt.lib \
+  libboost_filesystem-vc100-mt.lib \
+  libboost_program_options-vc100-mt.lib \
+  libboost_thread-vc100-mt.lib \
+  libdb47s.lib \
   libeay32.lib \
   kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib ws2_32.lib shlwapi.lib
 
 DEFS=/DWIN32 /D__WXMSW__ /D_WINDOWS /DNOPCH
-DEBUGFLAGS=/Zi /D__WXDEBUG__
-CFLAGS=/c /nologo /MDd /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
+DEBUGFLAGS=/Os
+CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
 HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \
     script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h
 
@@ -82,7 +85,7 @@
     rc $(INCLUDEPATHS) $(DEFS) /Fo$@ %s
 
 bitcoin.exe: $(OBJS) obj\ui.obj obj\uibase.obj obj\ui.res
-    link /nologo /DEBUG /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)
+    link /nologo /SUBSYSTEM:WINDOWS /OUT:$@ $(LIBPATHS) $** $(WXLIBS) $(LIBS)
 
 
 .cpp{obj\nogui}.obj:
@@ -105,7 +108,7 @@
 obj\nogui\init.obj: $(HEADERS)
 
 bitcoind.exe: $(OBJS:obj\=obj\nogui\) obj\ui.res
-    link /nologo /DEBUG /OUT:$@ $(LIBPATHS) $** $(LIBS)
+    link /nologo /OUT:$@ $(LIBPATHS) $** $(LIBS)
 
 
 clean:
--- a/net.cpp
+++ b/net.cpp
@@ -688,25 +688,18 @@
             socklen_t len = sizeof(sockaddr);
             SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);
             CAddress addr(sockaddr);
-            bool fLimitConnections = false;
             int nInbound = 0;
 
-            if (mapArgs.count("-maxconnections"))
-                fLimitConnections = true;
-
-            if (fLimitConnections)
-            {
-                CRITICAL_BLOCK(cs_vNodes)
-                    foreach(CNode* pnode, vNodes)
-                    if (pnode->fInbound)
-                        nInbound++;
-            }
+            CRITICAL_BLOCK(cs_vNodes)
+                foreach(CNode* pnode, vNodes)
+                if (pnode->fInbound)
+                    nInbound++;
             if (hSocket == INVALID_SOCKET)
             {
                 if (WSAGetLastError() != WSAEWOULDBLOCK)
                     printf("socket error accept failed: %d\n", WSAGetLastError());
             }
-            else if (fLimitConnections && nInbound >= atoi(mapArgs["-maxconnections"]) - MAX_OUTBOUND_CONNECTIONS)
+            else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
             {
                 closesocket(hSocket);
             }
@@ -748,32 +741,39 @@
                     CDataStream& vRecv = pnode->vRecv;
                     unsigned int nPos = vRecv.size();
 
-                    // typical socket buffer is 8K-64K
-                    char pchBuf[0x10000];
-                    int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
-                    if (nBytes > 0)
-                    {
-                        vRecv.resize(nPos + nBytes);
-                        memcpy(&vRecv[nPos], pchBuf, nBytes);
-                        pnode->nLastRecv = GetTime();
-                    }
-                    else if (nBytes == 0)
-                    {
-                        // socket closed gracefully
+                    if (nPos > 1000*GetArg("-maxreceivebuffer", 2*1000)) {
                         if (!pnode->fDisconnect)
-                            printf("socket closed\n");
+                            printf("socket recv flood control disconnect (%d bytes)\n", vRecv.size());
                         pnode->CloseSocketDisconnect();
                     }
-                    else if (nBytes < 0)
-                    {
-                        // error
-                        int nErr = WSAGetLastError();
-                        if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
+                    else {
+                        // typical socket buffer is 8K-64K
+                        char pchBuf[0x10000];
+                        int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
+                        if (nBytes > 0)
+                        {
+                            vRecv.resize(nPos + nBytes);
+                            memcpy(&vRecv[nPos], pchBuf, nBytes);
+                            pnode->nLastRecv = GetTime();
+                        }
+                        else if (nBytes == 0)
                         {
+                            // socket closed gracefully
                             if (!pnode->fDisconnect)
-                                printf("socket recv error %d\n", nErr);
+                                printf("socket closed\n");
                             pnode->CloseSocketDisconnect();
                         }
+                        else if (nBytes < 0)
+                        {
+                            // error
+                            int nErr = WSAGetLastError();
+                            if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
+                            {
+                                if (!pnode->fDisconnect)
+                                    printf("socket recv error %d\n", nErr);
+                                pnode->CloseSocketDisconnect();
+                            }
+                        }
                     }
                 }
             }
@@ -806,6 +806,11 @@
                                 pnode->CloseSocketDisconnect();
                             }
                         }
+                        if (vSend.size() > 1000*GetArg("-maxsendbuffer", 256)) {
+                            if (!pnode->fDisconnect)
+                                printf("socket send flood control disconnect (%d bytes)\n", vSend.size());
+                            pnode->CloseSocketDisconnect();
+                        }
                     }
                 }
             }
@@ -976,8 +981,7 @@
                     if (!pnode->fInbound)
                         nOutbound++;
             int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;
-            if (mapArgs.count("-maxconnections"))
-                nMaxOutboundConnections = min(nMaxOutboundConnections, atoi(mapArgs["-maxconnections"]));
+            nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));
             if (nOutbound < nMaxOutboundConnections)
                 break;
             Sleep(2000);
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -1015,13 +1015,13 @@
         for (map<uint256, CWalletTx>::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
         {
             CWalletTx* wtx = &((*it).second);
-            txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, 0)));
+            txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, (CAccountingEntry*)0)));
         }
         list<CAccountingEntry> acentries;
         walletdb.ListAccountCreditDebit(strAccount, acentries);
         foreach(CAccountingEntry& entry, acentries)
         {
-            txByTime.insert(make_pair(entry.nTime, TxPair(0, &entry)));
+            txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry)));
         }
 
         // Now: iterate backwards until we have nCount items to return:
@@ -1764,7 +1764,7 @@
         map<string, string> mapHeaders;
         string strRequest;
 
-        boost::thread api_caller(ReadHTTP, ref(stream), ref(mapHeaders), ref(strRequest));
+        boost::thread api_caller(ReadHTTP, boost::ref(stream), boost::ref(mapHeaders), boost::ref(strRequest));
         if (!api_caller.timed_join(boost::posix_time::seconds(GetArg("-rpctimeout", 30))))
         {   // Timed out:
             acceptor.cancel();
--- a/serialize.h
+++ b/serialize.h
@@ -25,7 +25,7 @@
 class CAutoFile;
 static const unsigned int MAX_SIZE = 0x02000000;
 
-static const int VERSION = 32000;
+static const int VERSION = 32001;
 static const char* pszSubVer = "";
 static const bool VERSION_IS_BETA = true;
 
@@ -763,6 +763,8 @@
     typedef typename base::value_type value_type;
     secure_allocator() throw() {}
     secure_allocator(const secure_allocator& a) throw() : base(a) {}
+    template <typename U>
+    secure_allocator(const secure_allocator<U>& a) throw() : base(a) {}
     ~secure_allocator() throw() {}
     template<typename _Other> struct rebind
     { typedef secure_allocator<_Other> other; };
--- a/setup.nsi
+++ b/setup.nsi
@@ -1,13 +1,10 @@
-# Auto-generated by EclipseNSIS Script Wizard
-# 3.10.2009 19:00:28
-
 Name Bitcoin
 
 RequestExecutionLevel highest
 
 # General Symbol Definitions
 !define REGKEY "SOFTWARE\$(^Name)"
-!define VERSION 0.3.19
+!define VERSION 0.3.20
 !define COMPANY "Bitcoin project"
 !define URL http://www.bitcoin.org/
 
@@ -42,12 +39,12 @@
 !insertmacro MUI_LANGUAGE English
 
 # Installer attributes
-OutFile bitcoin-0.3.19-win32-setup.exe
+OutFile bitcoin-0.3.20-win32-setup.exe
 InstallDir $PROGRAMFILES\Bitcoin
 CRCCheck on
 XPStyle on
 ShowInstDetails show
-VIProductVersion 0.3.19.0
+VIProductVersion 0.3.20.0
 VIAddVersionKey ProductName Bitcoin
 VIAddVersionKey ProductVersion "${VERSION}"
 VIAddVersionKey CompanyName "${COMPANY}"
@@ -64,7 +61,6 @@
     SetOverwrite on
     File bitcoin.exe
     File libeay32.dll
-    File mingwm10.dll
     File license.txt
     File readme.txt
     SetOutPath $INSTDIR\daemon
@@ -113,7 +109,6 @@
 Section /o -un.Main UNSEC0000
     Delete /REBOOTOK $INSTDIR\bitcoin.exe
     Delete /REBOOTOK $INSTDIR\libeay32.dll
-    Delete /REBOOTOK $INSTDIR\mingwm10.dll
     Delete /REBOOTOK $INSTDIR\license.txt
     Delete /REBOOTOK $INSTDIR\readme.txt
     RMDir /r /REBOOTOK $INSTDIR\daemon