Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6762797
Add back original libzip
iFoggz Oct 24, 2019
743d4ff
Add files to Makefiles
iFoggz Oct 24, 2019
fdb7027
Add snapshot and update check code to http.cpp/h
iFoggz Oct 24, 2019
527366a
Add upgrade.cpp/h
iFoggz Oct 24, 2019
3d1e3e9
Add upgradeqt.cpp/h
iFoggz Oct 24, 2019
9c1b042
Add -snapshotdownload option for qt and daemon startup and prep for m…
iFoggz Oct 24, 2019
b86a4b5
fixes and tweaks + menu option
iFoggz Oct 25, 2019
d128806
No update check/snapshot for TestNet
iFoggz Oct 26, 2019
fdd07ab
unsupported download speed fix
iFoggz Oct 27, 2019
58ff706
Add status of size and amount downloaded to progress plus small refactor
iFoggz Oct 27, 2019
0a37e4f
more changes
iFoggz Oct 29, 2019
6eea285
more
iFoggz Oct 29, 2019
2977d49
Support option in client to turn on and off update checks for current…
iFoggz Nov 6, 2019
294d9d2
Minor changes
iFoggz Nov 6, 2019
44ab4b9
Hide options dialog checkbox when running testnet
iFoggz Nov 6, 2019
6fa43f8
Allow -disableupdatecheck to also be an option in gridcoinresearch.co…
iFoggz Nov 6, 2019
08f50b1
resolves comments by cycy and jim owens. few extra changes such as de…
iFoggz Nov 8, 2019
1151bd0
static
iFoggz Nov 8, 2019
db509a5
remove excess flushing and shorten spacing
iFoggz Nov 8, 2019
0d9d9f4
some signed changes for zip process
iFoggz Nov 8, 2019
4723b65
Fix directory lock code and whoopsie
iFoggz Nov 8, 2019
c44f0e2
Try catch get_str() area and refactor for such, Remove fDisableUpdate…
iFoggz Nov 9, 2019
8ec3d21
Hide snapshot menu option when running testnet. Check for the argumen…
iFoggz Nov 10, 2019
206b2f7
typos
iFoggz Nov 10, 2019
9a25e3b
Initialize libcurl statically for thread-safety
cyrossignol Nov 11, 2019
990bdaa
Merge pull request #6 from cyrossignol/UpgradeUtilities
iFoggz Nov 11, 2019
b7ecd4e
use detailed text for changlog
iFoggz Nov 11, 2019
5698813
Refactor update message box
iFoggz Nov 11, 2019
fc7da7b
Close LevelDB before installing a snapshot
cyrossignol Nov 11, 2019
2814077
Merge pull request #7 from cyrossignol/UpgradeUtilities
iFoggz Nov 11, 2019
d6a7248
rename test to Snapshot
iFoggz Nov 11, 2019
c76533e
Catch Upgrade exceptions and guarentee delete of snapshot.zip and Upg…
iFoggz Nov 12, 2019
0fdaaa5
Clear structs in constructor
iFoggz Nov 12, 2019
ea2b2c7
Possible fix to windows issue; close file in sha256sum verification f…
iFoggz Nov 16, 2019
0542977
Delete snapshot.zip
iFoggz Nov 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ if test x$use_pkgconfig = xyes; then
[
PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
PKG_CHECK_MODULES([LIBZIP], [libzip],,[AC_MSG_ERROR(libzip not found.)])
PKG_CHECK_MODULES([CURL], [libcurl],,[AC_MSG_ERROR(libcurl not found.)])
if test x$use_qr != xno; then
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
Expand All @@ -998,6 +999,9 @@ else
AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),)
AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing))

AC_CHECK_HEADER([zipconf.h],,AC_MSG_ERROR(libzip headers missing))
AC_CHECK_LIB([zip], [main], LIBZIP_LIBS=-lzip, AC_MSG_ERROR(libzip missing))

AC_CHECK_HEADER([curl/curl.h],, AC_MSG_ERROR(libcurl headers missing),)
AC_CHECK_LIB([curl], [main],, AC_MSG_ERROR(libcurl missing))

Expand Down
1 change: 0 additions & 1 deletion depends/packages/libzip.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ endef
define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install
endef

4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DIST_SUBDIRS = univalue

AM_LDFLAGS = ${libcurl_LIBS} $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS)
AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
AM_CPPFLAGS = ${libcurl_CFLAGS} $(HARDENED_CPPFLAGS) -DSTATICLIB -DCURL_STATICLIB -DMINIUPNP_STATICLIB
AM_CPPFLAGS = ${libcurl_CFLAGS} $(HARDENED_CPPFLAGS) -DSTATICLIB -DCURL_STATICLIB -DMINIUPNP_STATICLIB -DZIP_STATIC -DNN_STATIC_LIB
EXTRA_LIBRARIES =

if EMBEDDED_UNIVALUE
Expand Down Expand Up @@ -132,6 +132,7 @@ GRIDCOIN_CORE_H = \
txdb-leveldb.h \
ui_interface.h \
uint256.h \
upgrade.h \
util/memory.h \
util/reverse_iterator.h \
util/strencodings.h \
Expand Down Expand Up @@ -202,6 +203,7 @@ GRIDCOIN_CORE_CPP = addrdb.cpp \
sync.cpp \
txdb-leveldb.cpp \
uint256.cpp \
upgrade.cpp \
util/strencodings.cpp \
util.cpp \
version.cpp \
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ GRIDCOINRESEARCH_QT_H = \
qt/transactionrecord.h \
qt/transactiontablemodel.h \
qt/transactionview.h \
qt/upgradeqt.h \
qt/votingdialog.h \
qt/walletmodel.h \
qt/winshutdownmonitor.h
Expand Down Expand Up @@ -222,6 +223,7 @@ GRIDCOINRESEARCH_QT_CPP = \
qt/transactionrecord.cpp \
qt/transactiontablemodel.cpp \
qt/transactionview.cpp \
qt/upgradeqt.cpp \
qt/votingdialog.cpp \
qt/walletmodel.cpp \
qt/winshutdownmonitor.cpp
Expand Down
41 changes: 39 additions & 2 deletions src/gridcoinresearchd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rpcserver.h"
#include "rpcclient.h"
#include "ui_interface.h"
#include "upgrade.h"

#include <boost/thread.hpp>
#include <boost/algorithm/string/predicate.hpp>
Expand Down Expand Up @@ -85,16 +86,52 @@ bool AppInit(int argc, char* argv[])
return false;
}

LogPrintf("AppInit");

if (!boost::filesystem::is_directory(GetDataDir(false)))
{
fprintf(stderr, "Error: Specified directory does not exist\n");
Shutdown(NULL);
}

/** Check here config file incase TestNet is set there and not in mapArgs **/
ReadConfigFile(mapArgs, mapMultiArgs);

// Check to see if the user requested a snapshot and we are not running TestNet!
if (mapArgs.count("-snapshotdownload") && !mapArgs.count("-testnet"))
{
Upgrade Snapshot;

// Let's check make sure gridcoin is not already running in the data directory.
// Use new probe feature
if (!LockDirectory(GetDataDir(), ".lock", false))
{
fprintf(stderr, "Cannot obtain a lock on data directory %s. Gridcoin is probably already running.", GetDataDir().string().c_str());

exit(1);
}

else
{
try
{
Snapshot.SnapshotMain();
}

catch (std::runtime_error& e)
{
LogPrintf("Snapshot Downloader: Runtime exception occured in SanpshotMain() (%s)", e.what());

Snapshot.DeleteSnapshot();

exit(1);
}
}

// Delete snapshot file
Snapshot.DeleteSnapshot();
}

LogPrintf("AppInit");

// Command-line RPC - Test this - ensure single commands execute and exit please.
for (int i = 1; i < argc; i++)
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "gridcoinresearchd"))
Expand Down
63 changes: 60 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "neuralnet/neuralnet.h"
#include "neuralnet/researcher.h"
#include "neuralnet/tally.h"
#include "upgrade.h"

#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
Expand Down Expand Up @@ -57,12 +58,13 @@ extern unsigned int nActiveBeforeSB;
extern bool fExplorer;
extern bool fUseFastIndex;
extern boost::filesystem::path pathScraper;

bool fSnapshotRequest = false;
// Dump addresses to banlist.dat every 5 minutes (300 s)
static constexpr int DUMP_BANS_INTERVAL = 300;

std::unique_ptr<BanMan> g_banman;

/** Update checker pointer for CScheduler; **/
std::unique_ptr<Upgrade> g_UpdateChecker;

//////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -285,7 +287,15 @@ std::string HelpMessage()
" -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n" +
" -rpcsslcertificatechainfile=<file.cert> " + _("Server certificate file (default: server.cert)") + "\n" +
" -rpcsslprivatekeyfile=<file.pem> " + _("Server private key (default: server.pem)") + "\n" +
" -rpcsslciphers=<ciphers> " + _("Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH)") + "\n";
" -rpcsslciphers=<ciphers> " + _("Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH)") + "\n"

"\n" + _("Update/Snapshot options:") + "\n"
" -snapshotdownload " + _("Download and apply latest snapshot") + "\n"
" -snapshoturl=<url> " + _("Optional: Specify url of snapshot.zip file (ex: https://sub.domain.com/location/snapshot.zip)") + "\n"
" -snapshotsha256url=<url> " + _("Optional: Specify url of snapshot.sha256 file (ex: https://sub.domain.com/location/snapshot.sha256)") + "\n"
" -disableupdatecheck " + _("Optional: Disable update checks by wallet") + "\n"
" -updatecheckinterval=<hours> " + _("Optional: Specify custom update interval checks in hours (Default: 24 hours (minimum 1 hour))") + "\n"
" -updatecheckurl=<url> " + _("Optional: Specify url of update version checks (ex: https://sub.domain.com/location/latest") + "\n";

return strUsage;
}
Expand Down Expand Up @@ -1043,6 +1053,53 @@ bool AppInit2(ThreadHandlerPtr threads)
g_banman->DumpBanlist();
}, DUMP_BANS_INTERVAL * 1000);

/** If this is not TestNet we check for updates on startup and daily **/
/** We still add to the scheduler regardless of the users choice however the choice is respected when they opt out**/
if (!fTestNet)
{
int64_t UpdateCheckInterval = 24;

// Save some cycles and only so this area if the argument exists
if (mapArgs.count("-updatecheckinterval"))
{
try
{
UpdateCheckInterval = GetArg("-updatecheckinterval", 24);
// trivial: Don't allow checks less then 1 hour apart of update checks to prevent server DDoS (what is a good value)
if (UpdateCheckInterval < 1)
{
LogPrintf("UpdateChecker: Update check interval too small of %" PRId64 "; Defaulting to 24 hour intervals", UpdateCheckInterval);

UpdateCheckInterval = 24;
}
}

catch (const std::exception& ex)
{
// Tell them the exception and what they had put in place
LogPrintf("UpdateChecker: Exception occured while obtaining interval for update checks (ex: %s -updatecheckinterval=%s); Defaulting to 24 hour intervals", ex.what(), GetArgument("-updatecheckinterval", ""));

UpdateCheckInterval = 24;
}
}

scheduler.scheduleEvery([]{g_UpdateChecker->CheckForLatestUpdate();}, UpdateCheckInterval * 60 * 60 * 1000);

if (!GetBoolArg("-disableupdatecheck", false))
{
LogPrintf("UpdateChecker: Update checks scheduled every %" PRId64 " hours.", UpdateCheckInterval);

LogPrintf("Updatechecker: Performing startup update check.");

g_UpdateChecker->CheckForLatestUpdate();
}

else
LogPrintf("UpdateChecker: Update checks are disabled by user.");
}

else
LogPrintf("UpdateChecker: Update checks are disable for TestNet.");

return true;
}
1 change: 1 addition & 0 deletions src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ std::string HelpMessage();
std::string VersionMessage();
std::string LogSomething();

extern bool fSnapshotRequest;
#endif
11 changes: 11 additions & 0 deletions src/noui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ static bool noui_ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCa
return true;
}

static int noui_UpdateMessageBox(const std::string& version, const std::string& message)
{
std::string caption = _("Gridcoin Update Available");

LogPrintf("%s:\r\n%s", caption, message);
fprintf(stderr, "\r\n%s:\r\n%s\r\n%s\r\n", caption.c_str(), version.c_str(), message.c_str());

return 0;
}

void noui_connect()
{
// Connect bitcoind signal handlers
uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox);
uiInterface.ThreadSafeAskFee.connect(noui_ThreadSafeAskFee);
uiInterface.UpdateMessageBox.connect(noui_UpdateMessageBox);
}
Loading