forked from ClearNode/Clearcore-Project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pedro-at-decenomy
committed
May 10, 2024
1 parent
b73edd8
commit 693abdd
Showing
33 changed files
with
620 additions
and
1,851 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# =========================================================================== | ||
# https://www.gnu.org/software/autoconf-archive/ax_boost_json.html | ||
# =========================================================================== | ||
# | ||
# SYNOPSIS | ||
# | ||
# AX_BOOST_JSON | ||
# | ||
# DESCRIPTION | ||
# | ||
# Test for the JSON library from the Boost C++ libraries. The macro | ||
# requires a preceding call to AX_BOOST_BASE. Further documentation is | ||
# available at <http://randspringer.de/boost/index.html>. | ||
# | ||
# This macro calls: | ||
# | ||
# AC_SUBST(BOOST_JSON_LIB) | ||
# | ||
# And sets: | ||
# | ||
# HAVE_BOOST_JSON | ||
# | ||
# LICENSE | ||
# | ||
# Copyright (c) 2008 Thomas Porschberg <[email protected]> | ||
# Copyright (c) 2008 Michael Tindal | ||
# Copyright (c) 2013 Daniel Casimiro <[email protected]> | ||
# Copyright (c) 2021 Richard Winters <[email protected]> | ||
# Copyright (c) 2022 Luke Mewburn <[email protected]> | ||
# | ||
# Copying and distribution of this file, with or without modification, are | ||
# permitted in any medium without royalty provided the copyright notice | ||
# and this notice are preserved. This file is offered as-is, without any | ||
# warranty. | ||
|
||
#serial 2 | ||
|
||
AC_DEFUN([AX_BOOST_JSON], [ | ||
AC_ARG_WITH([boost-json], | ||
AS_HELP_STRING([--with-boost-json@<:@=special-lib@:>@], | ||
[use the JSON library from boost - it is possible to specify a certain library for the linker | ||
e.g. --with-boost-json=boost_json-gcc-mt ] | ||
), [ | ||
if test "$withval" = "no"; then | ||
want_boost="no" | ||
elif test "$withval" = "yes"; then | ||
want_boost="yes" | ||
ax_boost_user_json_lib="" | ||
else | ||
want_boost="yes" | ||
ax_boost_user_json_lib="$withval" | ||
fi | ||
], [want_boost="yes"] | ||
) | ||
if test "x$want_boost" = "xyes"; then | ||
AC_REQUIRE([AC_PROG_CC]) | ||
AC_REQUIRE([AC_CANONICAL_BUILD]) | ||
CPPFLAGS_SAVED="$CPPFLAGS" | ||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" | ||
export CPPFLAGS | ||
LDFLAGS_SAVED="$LDFLAGS" | ||
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" | ||
export LDFLAGS | ||
AC_CACHE_CHECK(whether the Boost::JSON library is available, | ||
ax_cv_boost_json, [ | ||
AC_LANG_PUSH([C++]) | ||
CXXFLAGS_SAVE=$CXXFLAGS | ||
AC_COMPILE_IFELSE([ | ||
AC_LANG_PROGRAM([[@%:@include <boost/json.hpp>]], | ||
dnl XXXLUKEM | ||
[[boost::json::object obj; obj["ax"] = 1; std::string s = boost::json::serialize(obj);]]) | ||
], | ||
ax_cv_boost_json=yes, | ||
ax_cv_boost_json=no | ||
) | ||
CXXFLAGS=$CXXFLAGS_SAVE | ||
AC_LANG_POP([C++]) | ||
]) | ||
if test "x$ax_cv_boost_json" = "xyes"; then | ||
AC_SUBST(BOOST_CPPFLAGS) | ||
AC_DEFINE(HAVE_BOOST_JSON,,[define if the Boost::JSON library is available]) | ||
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` | ||
LDFLAGS_SAVE=$LDFLAGS | ||
if test "x$ax_boost_user_json_lib" = "x"; then | ||
for libextension in `ls $BOOSTLIBDIR/libboost_json*.so* $BOOSTLIBDIR/libboost_json*.dylib* $BOOSTLIBDIR/libboost_json*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_json.*\)\.so.*$;\1;' -e 's;^lib\(boost_json.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_json.*\)\.a.*$;\1;'` ; do | ||
ax_lib=${libextension} | ||
AC_CHECK_LIB($ax_lib, exit, | ||
[BOOST_JSON_LIB="-l$ax_lib"; AC_SUBST(BOOST_JSON_LIB) link_json="yes"; break], | ||
[link_json="no"] | ||
) | ||
done | ||
if test "x$link_json" != "xyes"; then | ||
for libextension in `ls $BOOSTLIBDIR/boost_json*.dll* $BOOSTLIBDIR/boost_json*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_json.*\)\.dll.*$;\1;' -e 's;^\(boost_json.*\)\.a.*$;\1;'` ; do | ||
ax_lib=${libextension} | ||
AC_CHECK_LIB($ax_lib, exit, | ||
[BOOST_JSON_LIB="-l$ax_lib"; AC_SUBST(BOOST_JSON_LIB) link_json="yes"; break], | ||
[link_json="no"] | ||
) | ||
done | ||
fi | ||
else | ||
for ax_lib in $ax_boost_user_json_lib boost_json-$ax_boost_user_json_lib; do | ||
AC_CHECK_LIB($ax_lib, exit, | ||
[BOOST_JSON_LIB="-l$ax_lib"; AC_SUBST(BOOST_JSON_LIB) link_json="yes"; break], | ||
[link_json="no"] | ||
) | ||
done | ||
fi | ||
if test "x$ax_lib" = "x"; then | ||
AC_MSG_ERROR(Could not find a version of the Boost::JSON library!) | ||
fi | ||
if test "x$link_json" = "xno"; then | ||
AC_MSG_ERROR(Could not link against $ax_lib !) | ||
fi | ||
fi | ||
CPPFLAGS="$CPPFLAGS_SAVED" | ||
LDFLAGS="$LDFLAGS_SAVED" | ||
fi | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Copyright (c) 2024 The DECENOMY Core Developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include "bootstrap.h" | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config/pivx-config.h" | ||
#endif | ||
|
||
#include "amount.h" | ||
#include "chainparams.h" | ||
#include "curl.h" | ||
#include "guiinterface.h" | ||
#include "util.h" | ||
#include "zip.h" | ||
|
||
#include <iostream> | ||
|
||
namespace fs = boost::filesystem; | ||
|
||
std::string extractFilenameFromURL(const std::string& url) | ||
{ | ||
// Find the last '/' in the URL, which is expected to precede the filename | ||
size_t last_slash_pos = url.find_last_of("/"); | ||
|
||
// Check if the last slash position is valid and there are characters after the '/' | ||
if (last_slash_pos != std::string::npos && last_slash_pos + 1 < url.size()) { | ||
return url.substr(last_slash_pos + 1); | ||
} | ||
|
||
// If no '/' found, or there is nothing after the last '/', return an empty string | ||
return ""; | ||
} | ||
|
||
int progressCallback( | ||
void* clientp, | ||
curl_off_t dltotal, | ||
curl_off_t dlnow, | ||
curl_off_t ultotal, | ||
curl_off_t ulnow) | ||
{ | ||
static int progress = 0; | ||
const auto currentProgress = dltotal > 0 ? (int)((dlnow * 100) / dltotal) : 0; | ||
|
||
if (currentProgress > progress) { | ||
progress = currentProgress; | ||
LogPrintf("CBootstrap::%s: Download: %d%%\n", __func__, progress); | ||
uiInterface.ShowProgress(_("Download: "), progress); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
bool CBootstrap::DownloadAndApply() | ||
{ | ||
const auto url = | ||
std::string(BOOTSTRAP_URL) + | ||
(Params().IsTestNet() ? "T" : "") + std::string(CURRENCY_UNIT) + | ||
"/bootstrap.zip"; | ||
const auto datadir = GetDataDir(); | ||
const auto fileName = datadir / extractFilenameFromURL(url); | ||
const auto blocks = datadir / "blocks"; | ||
const auto chainstate = datadir / "chainstate"; | ||
const auto sporks = datadir / "sporks"; | ||
const auto banlist = datadir / "banlist.dat"; | ||
|
||
try { | ||
// Step 1: Download the bootstrap file | ||
if (!CCurlWrapper::DownloadFile(url, fileName.string(), progressCallback)) { | ||
LogPrintf( | ||
"CBootstrap::%s: Failed to download the bootstrap file: %s\n", | ||
__func__, | ||
fileName.string()); | ||
return false; | ||
} | ||
|
||
// Step 2: Cleanup the existing folders and files | ||
try { | ||
fs::remove_all(blocks); | ||
fs::remove_all(chainstate); | ||
fs::remove_all(sporks); | ||
fs::remove_all(banlist); | ||
} catch (const boost::filesystem::filesystem_error& e) { | ||
LogPrintf("CBootstrap::%s: Error removing: %s\n", __func__, e.what()); | ||
return false; | ||
} | ||
|
||
// Step 3: Unzip the downloaded file | ||
if (!CZipWrapper::ExtractZip(fileName.string(), datadir.string())) { | ||
LogPrintf( | ||
"CBootstrap::%s: Failed to unzip the bootstrap file: %s into: %s\n", | ||
__func__, fileName.string(), datadir.string()); | ||
fs::remove_all(fileName); | ||
fs::remove_all(blocks); | ||
fs::remove_all(chainstate); | ||
fs::remove_all(sporks); | ||
fs::remove_all(banlist); | ||
|
||
return false; | ||
} | ||
|
||
// Step 4: Cleanup the bootstrap file | ||
fs::remove_all(fileName); | ||
|
||
} catch (const std::exception& e) { | ||
LogPrintf( | ||
"CBootstrap::%s: Error downloading bootstrap file: %s\n", | ||
__func__, e.what()); | ||
|
||
fs::remove_all(fileName); | ||
fs::remove_all(blocks); | ||
fs::remove_all(chainstate); | ||
fs::remove_all(sporks); | ||
fs::remove_all(banlist); | ||
|
||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) 2024 The DECENOMY Core Developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BOOTSTRAP_H | ||
#define BOOTSTRAP_H | ||
|
||
#define APPLE_CA_PATH "/etc/ssl/cert.pem" | ||
|
||
class CBootstrap | ||
{ | ||
public: | ||
static bool DownloadAndApply(); | ||
}; | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.