Skip to content

Commit

Permalink
Add bootstrap RPC command to daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
hd4r committed Sep 30, 2017
1 parent 1f13b4d commit 22427d2
Show file tree
Hide file tree
Showing 17 changed files with 415 additions and 10 deletions.
19 changes: 19 additions & 0 deletions COPYING
Expand Up @@ -21,3 +21,22 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

===============================================================================
src/miniunz.cpp is licensed under the following license:

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
2 changes: 1 addition & 1 deletion doc/README
Expand Up @@ -24,7 +24,7 @@ Quick Linux Build

-All typical Dependencies for Debian Build (git is optional) after installing qt

sudo apt-get install build-essential libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev libqrencode-dev git
sudo apt-get install build-essential libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev libqrencode-dev git libcurl4-gnutls-dev libminizip-dev

cd src
make -f makefile.unix
Expand Down
2 changes: 1 addition & 1 deletion doc/build-osx.txt
Expand Up @@ -35,7 +35,7 @@ but you can get the current version from http://developer.apple.com

2. Install dependencies from MacPorts

sudo port install boost db48 openssl miniupnpc qt5-mac gcc49 wget
sudo port install boost db48 openssl miniupnpc qt5-mac gcc49 wget minizip curl

Optionally install qrencode (and set USE_QRCODE=1):
sudo port install qrencode
Expand Down
25 changes: 23 additions & 2 deletions doc/build-unix.txt
Expand Up @@ -13,7 +13,7 @@ UNIX BUILD NOTES
Dependency Build Instructions: Ubuntu & Debian
----------------------------------------------

sudo apt-get install build-essential libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev libqrencode-dev freeglut3-dev git
sudo apt-get install build-essential libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev libqrencode-dev freeglut3-dev git libcurl4-gnutls-dev libminizip-dev

If using Boost 1.37, append -mt to the boost libraries in the makefile.

Expand All @@ -35,6 +35,8 @@ Dependencies
libboost Boost C++ Library
miniupnpc UPnP Support Optional firewall-jumping support
libqrencode QRCode generation Optional QRCode generation
libcurl File download Bootstrap zip download
libminizip Unzip Unzip bootstrap zip

Note that libexecinfo should be installed, if you building under *BSD systems.
This library provides backtrace facility.
Expand Down Expand Up @@ -72,7 +74,7 @@ Note: If you just want to install veriumd on Gentoo, you can add the Verium
overlay and use your package manager:
layman -a verium && emerge veriumd

emerge -av1 --noreplace boost glib openssl sys-libs/db
USE="minizip" emerge -av1 --noreplace boost glib openssl sys-libs/db net-misc/curl sys-libs/zlib

Take the following steps to build (no UPnP support):
cd ${VERICOIN_DIR}/src
Expand Down Expand Up @@ -136,6 +138,25 @@ configure --prefix=/usr --enable-static --disable-shared --without-tools
make


libminizip
----------
cd minizip-1.1
autoreconf -i
configure --prefix=/usr --disable-shared --enable-static
make
sudo su
make install


libcurl
-------
cd curl-7.55.1
configure --prefix=/usr --disable-shared --enable-static
make
sudo su
make install


Security
--------
To help make your verium installation more secure by making certain attacks impossible to
Expand Down
11 changes: 11 additions & 0 deletions src/bitcoinrpc.cpp
Expand Up @@ -25,6 +25,10 @@
#include <boost/shared_ptr.hpp>
#include <list>

#ifndef QT_GUI
#include <curl/curl.h>
#endif

#define printf OutputDebugStringF

using namespace std;
Expand Down Expand Up @@ -238,6 +242,9 @@ static const CRPCCommand vRPCCommands[] =
// ------------------------ ----------------------- ------ --------
{ "help", &help, true, true },
{ "stop", &stop, true, true },
#ifndef QT_GUI
{ "bootstrap", &bootstrap, true, false },
#endif
{ "getbestblockhash", &getbestblockhash, true, false },
{ "getblockcount", &getblockcount, true, false },
{ "getconnectioncount", &getconnectioncount, true, false },
Expand Down Expand Up @@ -832,6 +839,10 @@ void ThreadRPCServer2(void* parg)
boost::system::error_code v6_only_error;
boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(io_service));

#ifndef QT_GUI
curl_global_init(CURL_GLOBAL_ALL); // needed for bootstrap RPC command
#endif

boost::signals2::signal<void ()> StopRequests;

bool fListening = false;
Expand Down
3 changes: 3 additions & 0 deletions src/bitcoinrpc.h
Expand Up @@ -209,6 +209,9 @@ extern json_spirit::Value decodescript(const json_spirit::Array& params, bool fH
extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, bool fHelp);
extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp);

#ifndef QT_GUI
extern json_spirit::Value bootstrap(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
#endif
extern json_spirit::Value getbestblockhash(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp
extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp);
Expand Down
26 changes: 26 additions & 0 deletions src/init.cpp
Expand Up @@ -134,6 +134,32 @@ void Shutdown(void* parg)
RestartWallet(NULL, true);
}
}
#else
if (fBootstrapTurbo && boost::filesystem::exists(GetDataDir() / "bootstrap" / "blk0001.dat"))
{
try
{
// Leveldb instance destruction
CTxDB().Destroy();
boost::filesystem::rename(GetDataDir() / "bootstrap" / "blk0001.dat", GetDataDir() / "blk0001.dat");
boost::filesystem::rename(GetDataDir() / "bootstrap" / "txleveldb", GetDataDir() / "txleveldb");
boost::filesystem::remove_all(GetDataDir() / "bootstrap");

boost::filesystem::path pathBootstrapTurbo(GetDataDir() / "bootstrap_VRM.zip");
boost::filesystem::path pathBootstrap(GetDataDir() / "bootstrap.dat");
if (boost::filesystem::exists(pathBootstrapTurbo))
{
boost::filesystem::remove(pathBootstrapTurbo);
}
if (boost::filesystem::exists(pathBootstrap))
{
boost::filesystem::remove(pathBootstrap);
}
}
catch (std::exception &e) {
printf("Bootstrapturbo filesystem error!\n");
}
}
#endif
boost::filesystem::remove(GetPidFile());
UnregisterWallet(pwalletMain);
Expand Down
1 change: 1 addition & 0 deletions src/makefile.bsd
Expand Up @@ -132,6 +132,7 @@ OBJS= \
obj/scrypt-arm.o \
obj/scrypt-x86.o \
obj/scrypt-x86_64.o \
obj/miniunz.o \
obj/zerocoin/Accumulator.o \
obj/zerocoin/AccumulatorProofOfKnowledge.o \
obj/zerocoin/Coin.o \
Expand Down
5 changes: 4 additions & 1 deletion src/makefile.linux-mingw
Expand Up @@ -35,7 +35,9 @@ LIBS= \
-l boost_chrono-mt \
-l db_cxx \
-l ssl \
-l crypto
-l crypto \
-l curl \
-l minizip

DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
Expand Down Expand Up @@ -94,6 +96,7 @@ OBJS= \
obj/scrypt.o \
obj/scrypt-x86.o \
obj/scrypt-x86_64.o \
obj/miniunz.o \
obj/zerocoin/Accumulator.o \
obj/zerocoin/AccumulatorProofOfKnowledge.o \
obj/zerocoin/Coin.o \
Expand Down
5 changes: 4 additions & 1 deletion src/makefile.mingw
Expand Up @@ -32,7 +32,9 @@ LIBS= \
-l boost_chrono$(BOOST_SUFFIX) \
-l db_cxx \
-l ssl \
-l crypto
-l crypto \
-l curl \
-l minizip

DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__NO_SYSTEM_INCLUDES
DEBUGFLAGS=-g
Expand Down Expand Up @@ -94,6 +96,7 @@ OBJS= \
obj/scrypt.o \
obj/scrypt-x86.o \
obj/scrypt-x86_64.o \
obj/miniunz.o \
obj/zerocoin/Accumulator.o \
obj/zerocoin/AccumulatorProofOfKnowledge.o \
obj/zerocoin/Coin.o \
Expand Down
5 changes: 4 additions & 1 deletion src/makefile.osx
Expand Up @@ -45,7 +45,9 @@ LIBS += \
-lboost_thread-mt \
-lssl \
-lcrypto \
-lz
-lz \
-lcurl \
-lminizip
endif

DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE -DUSE_IPV6
Expand Down Expand Up @@ -86,6 +88,7 @@ OBJS= \
obj/walletdb.o \
obj/noui.o \
obj/scrypt.o \
obj/miniunz.o \

ifndef USE_UPNP
override USE_UPNP = -
Expand Down
5 changes: 4 additions & 1 deletion src/makefile.unix
Expand Up @@ -31,7 +31,9 @@ LIBS += \
-l boost_thread$(BOOST_LIB_SUFFIX) \
-l db_cxx$(BDB_LIB_SUFFIX) \
-l ssl \
-l crypto
-l crypto \
-l curl \
-l minizip

ifndef USE_UPNP
override USE_UPNP = -
Expand Down Expand Up @@ -133,6 +135,7 @@ OBJS= \
obj/walletdb.o \
obj/noui.o \
obj/scrypt.o \
obj/miniunz.o

all: veriumd

Expand Down

0 comments on commit 22427d2

Please sign in to comment.