From 85663f2c1886cf867ebe8c5b11b5d8fea10f6e82 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 15 May 2011 16:50:28 +0200 Subject: [PATCH] update to bitcoin-git --- TODO | 13 ++++++++----- core/include/base58.h | 4 ++-- core/include/net.h | 5 ++++- core/include/util.h | 3 ++- core/src/net.cpp | 10 ++++++---- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index d1713ebacf..dceee9b24d 100644 --- a/TODO +++ b/TODO @@ -66,17 +66,20 @@ AboutDialog Done: -Compatibility with Qt, and some more modularity +To be able to make an external GUI, I am working on modularizing bitcoin into a library. This is basic code +plumbing, 100% no functional changes. - Put guard statements around header files. -- Removed macro foreach: conflicts with Qt keyword foreach, replaced back with BOOST_FOREACH +- Removed macro foreach: conflicts with Qt4 keyword `foreach`, replaced with BOOST_FOREACH. - Prefix stdlib structures and functions with std:: in headers; "using namespace" in header files is - generally frowned upon + generally frowned upon. These are moved to the implementation files. + +- Modularity: base48.h and most other header files can now be included without the other shebang + (useful for linking external GUI to bitcoin core, part of GUI separation). + The include files that need each other now include each other. -- Modularity: base48.h can now be included without including all the headers - (useful for linking external GUI to bitcoin core, part of GUI separation) Todo: diff --git a/core/include/base58.h b/core/include/base58.h index 7acdf63ae3..580bd3fc63 100644 --- a/core/include/base58.h +++ b/core/include/base58.h @@ -7,7 +7,7 @@ // Why base-58 instead of standard base-64 encoding? // - Don't want 0OIl characters that look the same in some fonts and // could be used to create visually identical looking account numbers. -// - A std::string with non-alphanumeric characters is not as easily accepted as an account number. +// - A string with non-alphanumeric characters is not as easily accepted as an account number. // - E-mail usually won't line-break if there's no punctuation to break at. // - Doubleclicking selects the whole number as one word if it's all alphanumeric. // @@ -74,7 +74,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) while (isspace(*psz)) psz++; - // Convert big endian std::string to bignum + // Convert big endian string to bignum for (const char* p = psz; *p; p++) { const char* p1 = strchr(pszBase58, *p); diff --git a/core/include/net.h b/core/include/net.h index 746dd02fe8..6bbcd64e42 100644 --- a/core/include/net.h +++ b/core/include/net.h @@ -6,9 +6,12 @@ #include #include -#include #include +#ifndef __WXMSW__ +#include +#endif + class CMessageHeader; class CAddress; class CInv; diff --git a/core/include/util.h b/core/include/util.h index 2d1d42975b..b1eabd52d5 100644 --- a/core/include/util.h +++ b/core/include/util.h @@ -5,11 +5,12 @@ #define BITCOIN_UTIL_H #include "uint256.h" -//#include "cryptopp/sha.h" +#ifndef __WXMSW__ #include #include #include +#endif #include #include #include diff --git a/core/src/net.cpp b/core/src/net.cpp index 4f489fdb57..1320781cb2 100644 --- a/core/src/net.cpp +++ b/core/src/net.cpp @@ -133,6 +133,8 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet) bool Lookup(const char *pszName, vector& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup, int portDefault, bool fAllowPort) { vaddr.clear(); + if (pszName[0] == 0) + return false; int port = portDefault; char psz[256]; char *pszHost = psz; @@ -158,11 +160,11 @@ bool Lookup(const char *pszName, vector& vaddr, int nServices, int nMa } } - struct in_addr addrIP; - if (inet_aton(pszHost, &addrIP)) + unsigned int addrIP = inet_addr(pszHost); + if (addrIP != INADDR_NONE) { // valid IP address passed - vaddr.push_back(CAddress(addrIP.s_addr, port, nServices)); + vaddr.push_back(CAddress(addrIP, port, nServices)); return true; } @@ -1527,7 +1529,7 @@ void StartNode(void* parg) if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) { vector vaddr; - if (NameLookup(pszHostName, vaddr, nLocalServices)) + if (Lookup(pszHostName, vaddr, nLocalServices, -1, true)) BOOST_FOREACH (const CAddress &addr, vaddr) if (addr.GetByte(3) != 127) {