diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 10 | ||||
-rw-r--r-- | src/main.h | 19 | ||||
-rw-r--r-- | src/makefile.mingw | 9 | ||||
-rw-r--r-- | src/makefile.osx | 2 | ||||
-rw-r--r-- | src/net.cpp | 5 | ||||
-rw-r--r-- | src/net.h | 24 | ||||
-rw-r--r-- | src/rpc.cpp | 22 | ||||
-rw-r--r-- | src/ui.cpp | 61 | ||||
-rw-r--r-- | src/util.cpp | 4 |
10 files changed, 119 insertions, 39 deletions
diff --git a/src/init.cpp b/src/init.cpp index 431c533a83..ad35708710 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -383,7 +383,7 @@ bool AppInit2(int argc, char* argv[]) { printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); - ScanForWalletTransactions(pindexRescan); + ScanForWalletTransactions(pindexRescan, true); printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); } diff --git a/src/main.cpp b/src/main.cpp index bd8f29c09b..0456041ee5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -731,13 +731,13 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi } // Don't accept it if it can't get into a block - if (nFees < GetMinFee(1000)) + if (nFees < GetMinFee(1000, true, true)) return error("AcceptToMemoryPool() : not enough fees"); // Continuously rate-limit free transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make other's transactions take longer to confirm. - if (nFees < MIN_TX_FEE) + if (nFees < MIN_RELAY_TX_FEE) { static CCriticalSection cs; static double dFreeCount; @@ -884,7 +884,7 @@ bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb, bool fCheckInputs) return false; } -int ScanForWalletTransactions(CBlockIndex* pindexStart) +int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) { int ret = 0; @@ -897,7 +897,7 @@ int ScanForWalletTransactions(CBlockIndex* pindexStart) block.ReadFromDisk(pindex, true); BOOST_FOREACH(CTransaction& tx, block.vtx) { - if (AddToWalletIfInvolvingMe(tx, &block)) + if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) ret++; } pindex = pindex->pnext; @@ -3329,7 +3329,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // Transaction fee required depends on block size bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority)); - int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree); + int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, true); // Connecting shouldn't fail due to dependency on other memory pool transactions // because we're already processing them in order of dependency diff --git a/src/main.h b/src/main.h index 92b73fe5ad..8d9b39f718 100644 --- a/src/main.h +++ b/src/main.h @@ -29,7 +29,8 @@ static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2; static const int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; static const int64 COIN = 100000000; static const int64 CENT = 1000000; -static const int64 MIN_TX_FEE = 50000; +static const int64 MIN_TX_FEE = CENT; +static const int64 MIN_RELAY_TX_FEE = 50000; static const int64 MAX_MONEY = 21000000 * COIN; inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } static const int COINBASE_MATURITY = 100; @@ -86,7 +87,7 @@ bool AddKey(const CKey& key); std::vector<unsigned char> GenerateNewKey(); bool AddToWallet(const CWalletTx& wtxIn); void WalletUpdateSpent(const COutPoint& prevout); -int ScanForWalletTransactions(CBlockIndex* pindexStart); +int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); void ReacceptWalletTransactions(); bool LoadBlockIndex(bool fAllowNew=true); void PrintBlockTree(); @@ -599,12 +600,14 @@ public: return dPriority > COIN * 144 / 250; } - int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true) const + int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=true, bool fForRelay=false) const { - // Base fee is 1 cent per kilobyte + // Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE + int64 nBaseFee = fForRelay ? MIN_RELAY_TX_FEE : MIN_TX_FEE; + unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK); unsigned int nNewBlockSize = nBlockSize + nBytes; - int64 nMinFee = (1 + (int64)nBytes / 1000) * MIN_TX_FEE; + int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee; if (fAllowFree) { @@ -623,11 +626,11 @@ public: } } - // To limit dust spam, require MIN_TX_FEE if any output is less than 0.01 - if (nMinFee < MIN_TX_FEE) + // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01 + if (nMinFee < nBaseFee) BOOST_FOREACH(const CTxOut& txout, vout) if (txout.nValue < CENT) - nMinFee = MIN_TX_FEE; + nMinFee = nBaseFee; // Raise the price as the block approaches full if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2) diff --git a/src/makefile.mingw b/src/makefile.mingw index 57ece3ba29..c3a964e8fc 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -7,14 +7,14 @@ USE_UPNP:=0 INCLUDEPATHS= \ -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:\openssl-1.0.0d-mgw\include" \ -I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \ -I"C:\wxWidgets-2.9.1-mgw\include" LIBPATHS= \ -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:\openssl-1.0.0d-mgw" \ -L"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib" WXLIBS= \ @@ -26,9 +26,10 @@ LIBS= \ -l boost_program_options-mgw45-mt-s-1_43 \ -l boost_thread-mgw45-mt-s-1_43 \ -l db_cxx \ - -l eay32 + -l ssl \ + -l crypto -DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH +DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL DEBUGFLAGS=-g -D__WXDEBUG__ CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ diff --git a/src/makefile.osx b/src/makefile.osx index 1e6993d69b..4836ea3f4f 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -47,7 +47,7 @@ OBJS= \ cryptopp/obj/sha.o \ cryptopp/obj/cpu.o -ifeq (USE_UPNP, 1) +ifdef USE_UPNP LIBS += $(DEPSDIR)/lib/libminiupnpc.a DEFS += -DUSE_UPNP=$(USE_UPNP) endif diff --git a/src/net.cpp b/src/net.cpp index 85a5f35d28..39360a334c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -88,8 +88,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet) setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); #endif - bool fRoutable = !(addrConnect.GetByte(3) == 10 || (addrConnect.GetByte(3) == 192 && addrConnect.GetByte(2) == 168)); - bool fProxy = (fUseProxy && fRoutable); + bool fProxy = (fUseProxy && addrConnect.IsRoutable()); struct sockaddr_in sockaddr = (fProxy ? addrProxy.GetSockAddr() : addrConnect.GetSockAddr()); if (connect(hSocket, (struct sockaddr*)&sockaddr, sizeof(sockaddr)) == SOCKET_ERROR) @@ -1062,7 +1061,7 @@ void DNSAddressSeed() for (int seed_idx = 0; seed_idx < ARRAYLEN(strDNSSeed); seed_idx++) { vector<CAddress> vaddr; - if (Lookup(strDNSSeed[seed_idx], vaddr, NODE_NETWORK, true)) + if (Lookup(strDNSSeed[seed_idx], vaddr, NODE_NETWORK, -1, true)) { BOOST_FOREACH (CAddress& addr, vaddr) { @@ -283,13 +283,29 @@ public: return (memcmp(pchReserved, pchIPv4, sizeof(pchIPv4)) == 0); } + bool IsRFC1918() const + { + return IsIPv4() && (GetByte(3) == 10 || + (GetByte(3) == 192 && GetByte(2) == 168) || + (GetByte(3) == 172 && + (GetByte(2) >= 16 && GetByte(2) <= 31))); + } + + bool IsRFC3927() const + { + return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); + } + + bool IsLocal() const + { + return IsIPv4() && (GetByte(3) == 127 || + GetByte(3) == 0); + } + bool IsRoutable() const { return IsValid() && - !(GetByte(3) == 10 || - (GetByte(3) == 192 && GetByte(2) == 168) || - GetByte(3) == 127 || - GetByte(3) == 0); + !(IsRFC1918() || IsRFC3927() || IsLocal()); } bool IsValid() const diff --git a/src/rpc.cpp b/src/rpc.cpp index 9efcbbb15a..530bef4a43 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -199,12 +199,26 @@ double GetDifficulty() { // Floating point number that is a multiple of the minimum difficulty, // minimum difficulty = 1.0. + if (pindexBest == NULL) return 1.0; - int nShift = 256 - 32 - 31; // to fit in a uint - double dMinimum = (CBigNum().SetCompact(bnProofOfWorkLimit.GetCompact()) >> nShift).getuint(); - double dCurrently = (CBigNum().SetCompact(pindexBest->nBits) >> nShift).getuint(); - return dMinimum / dCurrently; + int nShift = (pindexBest->nBits >> 24) & 0xff; + + double dDiff = + (double)0x0000ffff / (double)(pindexBest->nBits & 0x00ffffff); + + while (nShift < 29) + { + dDiff *= 256.0; + nShift++; + } + while (nShift > 29) + { + dDiff /= 256.0; + nShift--; + } + + return dDiff; } Value getdifficulty(const Array& params, bool fHelp) diff --git a/src/ui.cpp b/src/ui.cpp index 6e28435a35..cca473d82b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -18,6 +18,13 @@ CMyTaskBarIcon* ptaskbaricon = NULL; bool fClosedToTray = false; wxLocale g_locale; +#ifdef __WXMSW__ +double nScaleX = 1.0; +double nScaleY = 1.0; +#else +static const double nScaleX = 1.0; +static const double nScaleY = 1.0; +#endif @@ -263,9 +270,10 @@ CMainFrame::CMainFrame(wxWindow* parent) : CMainFrameBase(parent) fOnSetFocusAddress = false; fRefresh = false; m_choiceFilter->SetSelection(0); - double dResize = 1.0; + double dResize = nScaleX; #ifdef __WXMSW__ SetIcon(wxICON(bitcoin)); + SetSize(dResize * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); #else SetIcon(bitcoin80_xpm); SetBackgroundColour(m_toolBar->GetBackgroundColour()); @@ -1219,6 +1227,9 @@ void CMainFrame::OnListItemActivated(wxListEvent& event) CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetailsDialogBase(parent) { +#ifdef __WXMSW__ + SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); +#endif CRITICAL_BLOCK(cs_mapAddressBook) { string strHTML; @@ -1633,6 +1644,8 @@ COptionsDialog::COptionsDialog(wxWindow* parent) : COptionsDialogBase(parent) SelectPage(0); #ifndef __WXMSW__ SetSize(1.0 * GetSize().GetWidth(), 1.2 * GetSize().GetHeight()); +#else + SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); #endif #if defined(__WXGTK__) || defined(__WXMAC_OSX__) m_checkBoxStartOnSystemStartup->SetLabel(_("&Start Bitcoin on window system startup")); @@ -1803,6 +1816,8 @@ CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent) fontTmp.SetPointSize(8); m_staticTextMain->SetFont(fontTmp); SetSize(GetSize().GetWidth() + 44, GetSize().GetHeight() + 10); +#else + SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); #endif } @@ -1837,12 +1852,21 @@ CSendDialog::CSendDialog(wxWindow* parent, const wxString& strAddress) : CSendDi fontTmp.SetPointSize(9); m_staticTextInstructions->SetFont(fontTmp); SetSize(725, 180); +#else + SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); #endif // Set Icon - wxIcon iconSend; - iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm)); - SetIcon(iconSend); + if (nScaleX == 1.0 && nScaleY == 1.0) // We don't have icons of the proper size otherwise + { + wxIcon iconSend; + iconSend.CopyFromBitmap(wxBitmap(send16noshadow_xpm)); + SetIcon(iconSend); + } +#ifdef __WXMSW__ + else + SetIcon(wxICON(bitcoin)); +#endif // Fixup the tab order m_buttonPaste->MoveAfterInTabOrder(m_buttonCancel); @@ -1992,6 +2016,8 @@ CSendingDialog::CSendingDialog(wxWindow* parent, const CAddress& addrIn, int64 n fWorkDone = false; #ifndef __WXMSW__ SetSize(1.2 * GetSize().GetWidth(), 1.08 * GetSize().GetHeight()); +#else + SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); #endif SetTitle(strprintf(_("Sending %s to %s"), FormatMoney(nPrice).c_str(), wtx.mapValue["to"].c_str())); @@ -2315,6 +2341,10 @@ void CSendingDialog::OnReply3(CDataStream& vRecv) CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInitSelected, int nPageIn, bool fDuringSendIn) : CAddressBookDialogBase(parent) { +#ifdef __WXMSW__ + SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); +#endif + // Set initially selected page wxNotebookEvent event; event.SetSelection(nPageIn); @@ -2326,9 +2356,16 @@ CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInit m_buttonCancel->Show(false); // Set Icon - wxIcon iconAddressBook; - iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm)); - SetIcon(iconAddressBook); + if (nScaleX == 1.0 && nScaleY == 1.0) // We don't have icons of the proper size otherwise + { + wxIcon iconAddressBook; + iconAddressBook.CopyFromBitmap(wxBitmap(addressbook16_xpm)); + SetIcon(iconAddressBook); + } +#ifdef __WXMSW__ + else + SetIcon(wxICON(bitcoin)); +#endif // Init column headers m_listCtrlSending->InsertColumn(0, _("Name"), wxLIST_FORMAT_LEFT, 200); @@ -2844,6 +2881,16 @@ bool CMyApp::OnInit() g_locale.AddCatalog("wxstd"); // wxWidgets standard translations, if any g_locale.AddCatalog("bitcoin"); +#ifdef __WXMSW__ + HDC hdc = GetDC(NULL); + if (hdc) + { + nScaleX = GetDeviceCaps(hdc, LOGPIXELSX) / 96.0; + nScaleY = GetDeviceCaps(hdc, LOGPIXELSY) / 96.0; + ReleaseDC(NULL, hdc); + } +#endif + return AppInit(argc, argv); } diff --git a/src/util.cpp b/src/util.cpp index 4e93f625de..6199109289 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -271,7 +271,7 @@ string strprintf(const char* format, ...) if (ret >= 0 && ret < limit) break; if (p != buffer) - delete p; + delete[] p; limit *= 2; p = new char[limit]; if (p == NULL) @@ -279,7 +279,7 @@ string strprintf(const char* format, ...) } string str(p, p+ret); if (p != buffer) - delete p; + delete[] p; return str; } |