Skip to content

Commit

Permalink
Merge pull request #126 from 216k155/v4.3.1
Browse files Browse the repository at this point in the history
V4.3.1
  • Loading branch information
nguyenhoangtran11 committed Apr 9, 2018
2 parents 8b483d3 + a4709e8 commit 0cd6631
Show file tree
Hide file tree
Showing 43 changed files with 1,506 additions and 763 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 4)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
Expand Down
14 changes: 2 additions & 12 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ BITCOIN_CORE_H = \
compat.h \
compat/sanity.h \
compressor.h \
consensus/params.h \
primitives/block.h \
primitives/transaction.h \
core_io.h \
Expand Down Expand Up @@ -158,17 +159,6 @@ BITCOIN_CORE_H = \
zmq/zmqnotificationinterface.h \
zmq/zmqpublishnotifier.h

JSON_H = \
json/json_spirit.h \
json/json_spirit_error_position.h \
json/json_spirit_reader.h \
json/json_spirit_reader_template.h \
json/json_spirit_stream_reader.h \
json/json_spirit_utils.h \
json/json_spirit_value.h \
json/json_spirit_writer.h \
json/json_spirit_writer_template.h

obj/build.h: FORCE
@$(MKDIR_P) $(builddir)/obj
@$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \
Expand Down Expand Up @@ -204,7 +194,6 @@ libbitcoin_server_a_SOURCES = \
txdb.cpp \
txmempool.cpp \
validationinterface.cpp \
$(JSON_H) \
$(BITCOIN_CORE_H)

if ENABLE_ZMQ
Expand Down Expand Up @@ -382,6 +371,7 @@ luxd_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
# lux-cli binary #
lux_cli_LDADD = \
$(LIBBITCOIN_CLI) \
$(LIBBITCOIN_UNIVALUE) \
$(LIBBITCOIN_UTIL) \
$(BOOST_LIBS) \
$(SSL_LIBS) \
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "primitives/block.h"
#include "protocol.h"
#include "uint256.h"
#include "consensus/params.h"

#include <vector>

Expand Down Expand Up @@ -43,6 +44,7 @@ class CChainParams
};

const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
const Consensus::Params& GetConsensus() const { return consensus; }
const MessageStartChars& MessageStart() const { return pchMessageStart; }
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
int GetDefaultPort() const { return nDefaultPort; }
Expand Down Expand Up @@ -101,6 +103,7 @@ class CChainParams
CChainParams() {}

uint256 hashGenesisBlock;
Consensus::Params consensus;
MessageStartChars pchMessageStart;
//! Raw pub key bytes for the broadcast alert signing key.
std::vector<unsigned char> vAlertPubKey;
Expand Down
16 changes: 8 additions & 8 deletions src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ static const double SIGCHECK_VERIFICATION_FACTOR = 5.0;

bool fEnabled = true;

bool CheckBlock(int nHeight, const uint256& hash)
bool CheckBlock(const CCheckpointData& data, int nHeight, const uint256& hash)
{
if (!fEnabled)
return true;

const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
const MapCheckpoints& checkpoints = *data.mapCheckpoints;

MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
if (i == checkpoints.end()) return true;
return hash == i->second;
}

//! Guess how far we are in the verification process at the given block index
double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks)
double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex *pindex, bool fSigchecks)
{
if (pindex == NULL)
return 0.0;
Expand All @@ -53,7 +53,7 @@ double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks)
// Work is defined as: 1.0 per transaction before the last checkpoint, and
// fSigcheckVerificationFactor per transaction after.

const CCheckpointData& data = Params().Checkpoints();
// const CCheckpointData& data = Params().Checkpoints();

if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
double nCheapBefore = pindex->nChainTx;
Expand All @@ -72,22 +72,22 @@ double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks)
return fWorkBefore / (fWorkBefore + fWorkAfter);
}

int GetTotalBlocksEstimate()
int GetTotalBlocksEstimate(const CCheckpointData& data)
{
if (!fEnabled)
return 0;

const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
const MapCheckpoints& checkpoints = *data.mapCheckpoints;

return checkpoints.rbegin()->first;
}

CBlockIndex* GetLastCheckpoint()
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data)
{
if (!fEnabled)
return NULL;

const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
const MapCheckpoints& checkpoints = *data.mapCheckpoints;

BOOST_REVERSE_FOREACH (const MapCheckpoints::value_type& i, checkpoints) {
const uint256& hash = i.second;
Expand Down
8 changes: 4 additions & 4 deletions src/checkpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ struct CCheckpointData {
};

//! Returns true if block passes checkpoint checks
bool CheckBlock(int nHeight, const uint256& hash);
bool CheckBlock(const CCheckpointData& data, int nHeight, const uint256& hash);

//! Return conservative estimate of total number of blocks, 0 if unknown
int GetTotalBlocksEstimate();
int GetTotalBlocksEstimate(const CCheckpointData& data);

//! Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
CBlockIndex* GetLastCheckpoint();
CBlockIndex* GetLastCheckpoint(const CCheckpointData& data);

double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks = true);
double GuessVerificationProgress(const CCheckpointData& data, CBlockIndex* pindex, bool fSigchecks = true);

extern bool fEnabled;

Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! These need to be macros, as clientversion.cpp's and lux*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 4
#define CLIENT_VERSION_MINOR 3
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
Expand Down
32 changes: 32 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2017-2018 The Luxcore developers

#ifndef BITCOIN_CONSENSUS_PARAMS_H
#define BITCOIN_CONSENSUS_PARAMS_H

#include "uint256.h"

namespace Consensus {
/**
* Parameters that influence chain consensus.
*/
struct Params {
uint256 hashGenesisBlock;
int nSubsidyHalvingInterval;
/** Used to check majorities for block version upgrade */
int nEnforceBlockUpgradeMajority;
int nRejectBlockOutdatedMajority;
int nToCheckBlockUpgradeMajority;
/** Proof of work parameters */
int nLastPOWBlock;
int64_t nTargetSpacing;
int64_t nTargetTimespan;
/** Proof of stake parameters */
int64_t nStakingRoundPeriod;
int64_t nStakingInterval;
int64_t nStakingMinAge;
};
} // namespace Consensus

#endif // BITCOIN_CONSENSUS_PARAMS_H
4 changes: 2 additions & 2 deletions src/cpp-ethereum/test/libtesteth/ImportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ int ImportTest::compareStates(State const& _stateExpect, State const& _statePost

void parseJsonStrValueIntoVector(json_spirit::mValue const& _json, vector<string>& _out)
{
if (_json.type() == json_spirit::array_type)
if (_json.type() == UniValue_type)
{
for (auto const& val: _json.get_array())
_out.push_back(val.get_str());
Expand All @@ -444,7 +444,7 @@ void parseJsonStrValueIntoVector(json_spirit::mValue const& _json, vector<string

void parseJsonIntValueIntoVector(json_spirit::mValue const& _json, vector<int>& _out)
{
if (_json.type() == json_spirit::array_type)
if (_json.type() == UniValue_type)
{
for (auto const& val: _json.get_array())
_out.push_back(val.get_int());
Expand Down
4 changes: 2 additions & 2 deletions src/cpp-ethereum/test/libtesteth/TestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ bytes importCode(json_spirit::mObject& _o)
code = fromHex(compileLLL(_o["code"].get_str()));
else
code = fromHex(_o["code"].get_str().substr(2));
else if (_o["code"].type() == json_spirit::array_type)
else if (_o["code"].type() == UniValue_type)
{
code.clear();
for (auto const& j: _o["code"].get_array())
Expand Down Expand Up @@ -322,7 +322,7 @@ void checkOutput(bytesConstRef _output, json_spirit::mObject& _o)

if (expectedOutput.find("#") == 0)
BOOST_CHECK(_output.size() == toInt(expectedOutput.substr(1)));
else if (_o["out"].type() == json_spirit::array_type)
else if (_o["out"].type() == UniValue_type)
for (auto const& d: _o["out"].get_array())
{
BOOST_CHECK_MESSAGE(_output[j] == toInt(d), "Output byte [" << j << "] different!");
Expand Down
22 changes: 22 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,26 @@ bool static Bind(const CService& addr, unsigned int flags)
return true;
}

void OnRPCStopped()
{
cvBlockChange.notify_all();
LogPrint("rpc", "RPC stopped.\n");
}

void OnRPCPreCommand(const CRPCCommand& cmd)
{
#ifdef ENABLE_WALLET
if (cmd.reqWallet && !pwalletMain)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
#endif

// Observe safe mode
string strWarning = GetWarnings("rpc");
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
!cmd.okSafeMode)
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
}

std::string HelpMessage(HelpMessageMode mode)
{
// When adding new options to the categories, please keep and ensure alphabetical ordering.
Expand Down Expand Up @@ -919,6 +939,8 @@ bool AppInit2(boost::thread_group& threadGroup)
*/
if (fServer) {
uiInterface.InitMessage.connect(SetRPCWarmupStatus);
RPCServer::OnStopped(&OnRPCStopped);
RPCServer::OnPreCommand(&OnRPCPreCommand);
StartRPCThreads();
}

Expand Down
31 changes: 15 additions & 16 deletions src/lux-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
#include "rpcprotocol.h"
#include "util.h"
#include "utilstrencodings.h"

#include "univalue/univalue.h"
#include <boost/filesystem/operations.hpp>

#define _(x) std::string(x) /* Keep the _() around in case gettext or such will be used later to translate non-UI */

using namespace std;
using namespace boost;
using namespace boost::asio;
using namespace json_spirit;

std::string HelpMessageCli()
{
Expand Down Expand Up @@ -99,7 +98,7 @@ static bool AppInitRPC(int argc, char* argv[])
return true;
}

Object CallRPC(const string& strMethod, const Array& params)
UniValue CallRPC(const string& strMethod, const UniValue& params)
{
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
throw runtime_error(strprintf(
Expand Down Expand Up @@ -147,10 +146,10 @@ Object CallRPC(const string& strMethod, const Array& params)
throw runtime_error("no response from server");

// Parse reply
Value valReply;
if (!read_string(strReply, valReply))
UniValue valReply(UniValue::VSTR);
if (!valReply.read(strReply))
throw runtime_error("couldn't parse reply from server");
const Object& reply = valReply.get_obj();
const UniValue& reply = valReply.get_obj();
if (reply.empty())
throw runtime_error("expected reply to have result, error and id properties");

Expand All @@ -175,33 +174,33 @@ int CommandLineRPC(int argc, char* argv[])

// Parameters default to strings
std::vector<std::string> strParams(&argv[2], &argv[argc]);
Array params = RPCConvertValues(strMethod, strParams);
UniValue params = RPCConvertValues(strMethod, strParams);

// Execute and handle connection failures with -rpcwait
const bool fWait = GetBoolArg("-rpcwait", false);
do {
try {
const Object reply = CallRPC(strMethod, params);
const UniValue reply = CallRPC(strMethod, params);

// Parse reply
const Value& result = find_value(reply, "result");
const Value& error = find_value(reply, "error");
const UniValue& result = find_value(reply, "result");
const UniValue& error = find_value(reply, "error");

if (error.type() != null_type) {
if (!error.isNull()) {
// Error
const int code = find_value(error.get_obj(), "code").get_int();
int code = error["code"].get_int();
if (fWait && code == RPC_IN_WARMUP)
throw CConnectionFailed("server in warmup");
strPrint = "error: " + write_string(error, false);
strPrint = "error: " + error.write();
nRet = abs(code);
} else {
// Result
if (result.type() == null_type)
if (result.isNull())
strPrint = "";
else if (result.type() == str_type)
else if (result.isStr())
strPrint = result.get_str();
else
strPrint = write_string(result, true);
strPrint = result.write(2);
}

// Connection succeeded, no need to retry.
Expand Down
8 changes: 4 additions & 4 deletions src/lux-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static bool findSighashFlags(int& flags, const string& flagStr)
uint256 ParseHashUO(map<string, UniValue>& o, string strKey)
{
if (!o.count(strKey))
return 0;
return uint256();
return ParseHashUV(o[strKey], strKey);
}

Expand Down Expand Up @@ -353,7 +353,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
UniValue keysObj = registers["privatekeys"];
fGivenKeys = true;

for (unsigned int kidx = 0; kidx < keysObj.count(); kidx++) {
for (unsigned int kidx = 0; kidx < keysObj.size(); kidx++) {
if (!keysObj[kidx].isStr())
throw runtime_error("privatekey not a string");
CBitcoinSecret vchSecret;
Expand All @@ -370,7 +370,7 @@ static void MutateTxSign(CMutableTransaction& tx, const string& flagStr)
throw runtime_error("prevtxs register variable must be set.");
UniValue prevtxsObj = registers["prevtxs"];
{
for (unsigned int previdx = 0; previdx < prevtxsObj.count(); previdx++) {
for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
UniValue prevOut = prevtxsObj[previdx];
if (!prevOut.isObject())
throw runtime_error("expected prevtxs internal object");
Expand Down Expand Up @@ -484,7 +484,7 @@ static void MutateTx(CMutableTransaction& tx, const string& command, const strin
static void OutputTxJSON(const CTransaction& tx)
{
UniValue entry(UniValue::VOBJ);
TxToUniv(tx, 0, entry);
TxToUniv(tx, uint256(), entry);

string jsonOutput = entry.write(4);
fprintf(stdout, "%s\n", jsonOutput.c_str());
Expand Down

0 comments on commit 0cd6631

Please sign in to comment.