From: Gavin Andresen Date: Thu, 26 Apr 2012 22:36:33 +0000 (-0700) Subject: Merge pull request #1150 from gavinandresen/NOPCH X-Git-Tag: v0.4.0-unstable~129^2~42 X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=27d4b53a5c458b68921f406458cc72bfadb15fa5;hp=cfc45319fe675d5a03a67ebc69ef4de9f243dcbb;p=novacoin.git Merge pull request #1150 from gavinandresen/NOPCH Remove unused -DNOPCH --- diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 2262923..bafd00c 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -1441,7 +1441,6 @@ Value listsinceblock(const Array& params, bool fHelp) if (target_confirms == 1) { - printf("oops!\n"); lastblock = hashBestChain; } else diff --git a/src/compat.h b/src/compat.h index db34044..804a814 100644 --- a/src/compat.h +++ b/src/compat.h @@ -21,10 +21,8 @@ #include #include #include -#include -#endif -#ifdef BSD #include +#include #endif typedef u_int SOCKET; diff --git a/src/db.cpp b/src/db.cpp index 53da378..12647e5 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -28,6 +28,7 @@ unsigned int nWalletDBUpdated; CCriticalSection cs_db; static bool fDbEnvInit = false; +bool fDetachDB = false; DbEnv dbenv(0); map mapFileUseCount; static map mapDb; @@ -307,9 +308,13 @@ void DBFlush(bool fShutdown) { // Move log data to the dat file CloseDb(strFile); + printf("%s checkpoint\n", strFile.c_str()); dbenv.txn_checkpoint(0, 0, 0); - printf("%s flush\n", strFile.c_str()); - dbenv.lsn_reset(strFile.c_str(), 0); + if ((strFile != "blkindex.dat" && strFile != "addr.dat") || fDetachDB) { + printf("%s detach\n", strFile.c_str()); + dbenv.lsn_reset(strFile.c_str(), 0); + } + printf("%s closed\n", strFile.c_str()); mapFileUseCount.erase(mi++); } else diff --git a/src/db.h b/src/db.h index 48e10a9..3ce8f17 100644 --- a/src/db.h +++ b/src/db.h @@ -25,6 +25,7 @@ class CWallet; class CWalletTx; extern unsigned int nWalletDBUpdated; +extern bool fDetachDB; extern DbEnv dbenv; extern void DBFlush(bool fShutdown); diff --git a/src/init.cpp b/src/init.cpp index e7f1c7c..0671cd7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -200,6 +200,7 @@ bool AppInit2(int argc, char* argv[]) #else " -upnp \t " + _("Use Universal Plug and Play to map the listening port (default: 0)") + "\n" + #endif + " -detachdb \t " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + #endif " -paytxfee= \t " + _("Fee per KB to add to transactions you send") + "\n" + #ifdef QT_GUI @@ -255,6 +256,7 @@ bool AppInit2(int argc, char* argv[]) } fDebug = GetBoolArg("-debug"); + fDetachDB = GetBoolArg("-detachdb", false); #if !defined(WIN32) && !defined(QT_GUI) fDaemon = GetBoolArg("-daemon"); diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 9bef4d4..4c155f3 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -31,6 +31,7 @@ DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB DEBUGFLAGS=-g CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) ifdef USE_UPNP LIBPATHS += -L"$(DEPSDIR)/miniupnpc" @@ -78,20 +79,19 @@ obj/%.o: %.cpp $(HEADERS) bitcoind.exe: $(OBJS:obj/%=obj/%) i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) +TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) -obj/test/%.o: obj/test/%.cpp $(HEADERS) - i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< +obj-test/%.o: test/%.cpp $(HEADERS) + i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< -test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s +test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) + i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) clean: -rm -f obj/*.o - -rm -f obj/test/*.o - -rm -f test/*.o - -rm -f headers.h.gch -rm -f bitcoind.exe + -rm -f obj-test/*.o -rm -f test_bitcoin.exe -rm -f src/build.h diff --git a/src/makefile.mingw b/src/makefile.mingw index dcb46ef..917eb12 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -27,6 +27,7 @@ DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB DEBUGFLAGS=-g CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) ifdef USE_UPNP INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw" @@ -71,17 +72,16 @@ obj/%.o: %.cpp $(HEADERS) bitcoind.exe: $(OBJS:obj/%=obj/%) g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) - g++ -c $(CFLAGS) -o $@ test/test_bitcoin.cpp +TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) -test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) +obj-test/%.o: test/%.cpp $(HEADERS) + g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< + +test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) + g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) clean: -del /Q bitcoind test_bitcoin -del /Q obj\* - -del /Q obj\nogui\* - -del /Q obj\test\* - -del /Q test\*.o - -del /Q headers.h.gch + -del /Q obj-test\* -del /Q build.h diff --git a/src/makefile.osx b/src/makefile.osx index aaac670..be95aab 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -22,6 +22,9 @@ LIBPATHS= \ USE_UPNP:=1 LIBS= -dead_strip + +TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) + ifdef STATIC # Build STATIC if you are redistributing the bitcoind binary TESTLIBS += \ diff --git a/src/makefile.unix b/src/makefile.unix index 24ee06e..90be398 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -9,6 +9,8 @@ DEFS= DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) +TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) + LMODE = dynamic LMODE2 = dynamic ifdef STATIC diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 8233e42..59c44ac 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -38,6 +38,7 @@ private: QCheckBox *minimize_on_close; #endif QCheckBox *connect_socks4; + QCheckBox *detach_database; QLineEdit *proxy_ip; QLineEdit *proxy_port; BitcoinAmountField *fee_edit; @@ -229,6 +230,10 @@ MainOptionsPage::MainOptionsPage(QWidget *parent): layout->addLayout(fee_hbox); + detach_database = new QCheckBox(tr("Detach databases at shutdown")); + detach_database->setToolTip(tr("Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.")); + layout->addWidget(detach_database); + layout->addStretch(1); // Extra space at bottom setLayout(layout); @@ -256,6 +261,7 @@ void MainOptionsPage::setMapper(MonitoredDataMapper *mapper) mapper->addMapping(proxy_ip, OptionsModel::ProxyIP); mapper->addMapping(proxy_port, OptionsModel::ProxyPort); mapper->addMapping(fee_edit, OptionsModel::Fee); + mapper->addMapping(detach_database, OptionsModel::DetachDatabases); } DisplayOptionsPage::DisplayOptionsPage(QWidget *parent): diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 2210c4d..5bba308 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -28,6 +28,8 @@ void OptionsModel::Init() SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()); if (settings.contains("addrProxy") && settings.value("fUseProxy").toBool()) SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()); + if (settings.contains("detachDB")) + SoftSetBoolArg("-detachdb", settings.value("detachDB").toBool()); } bool OptionsModel::Upgrade() @@ -121,6 +123,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return QVariant(nDisplayUnit); case DisplayAddresses: return QVariant(bDisplayAddresses); + case DetachDatabases: + return QVariant(fDetachDB); default: return QVariant(); } @@ -204,6 +208,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in settings.setValue("bDisplayAddresses", bDisplayAddresses); } break; + case DetachDatabases: { + fDetachDB = value.toBool(); + settings.setValue("detachDB", fDetachDB); + } + break; default: break; } diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 0be70f8..da4e86f 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -26,7 +26,8 @@ public: Fee, // qint64 DisplayUnit, // BitcoinUnits::Unit DisplayAddresses, // bool - OptionIDRowCount + DetachDatabases, // bool + OptionIDRowCount, }; void Init(); diff --git a/src/script.cpp b/src/script.cpp index 660023e..65e9b7c 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -939,7 +939,7 @@ bool EvalScript(vector >& stack, const CScript& script, co { // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) - unsigned int i = 1; + int i = 1; if (stack.size() < i) return false; diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 988bd24..745df4b 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -5,8 +5,9 @@ #include #include #include -#include #include +#include +#include #include "json/json_spirit_reader_template.h" #include "json/json_spirit_writer_template.h" #include "json/json_spirit_utils.h" @@ -87,10 +88,13 @@ read_json(const std::string& filename) { namespace fs = boost::filesystem; fs::path testFile = fs::current_path() / "test" / "data" / filename; + +#ifdef TEST_DATA_DIR if (!fs::exists(testFile)) { - fs::path testFile = fs::path(__FILE__).parent_path() / "data" / filename; + testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename; } +#endif ifstream ifs(testFile.string().c_str(), ifstream::in); Value v;