Skip to content

Commit

Permalink
Merge pull request #278 from syscoin/dev-3.x
Browse files Browse the repository at this point in the history
Dev 3.x

Former-commit-id: 83cb7f1
  • Loading branch information
sidhujag committed Sep 9, 2018
2 parents 022451e + 1fd9803 commit 2817bd3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ env:
# Win64
- HOST=x86_64-w64-mingw32 DPKG_ADD_ARCH="i386" DEP_OPTS="NO_QT=1" PPA="ppa:bitcoin/bitcoin" PACKAGES="python3 nsis g++-mingw-w64-x86-64 wine1.7 bc" RUN_TESTS=false GOAL="install" SYSCOIN_CONFIG="--enable-gui --enable-reduce-exports" MAKEJOBS="-j4" WINE=true
# syscoindd
- HOST=x86_64-unknown-linux-gnu PPA="ppa:bitcoin/bitcoin" PACKAGES="bc python3-zmq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=false GOAL="install" SYSCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports" CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_SYS_DEBUG" PYZMQ=true
# - HOST=x86_64-unknown-linux-gnu PPA="ppa:bitcoin/bitcoin" PACKAGES="bc python3-zmq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=false GOAL="install" SYSCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports" CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_SYS_DEBUG" PYZMQ=true
# No wallet
# - HOST=x86_64-unknown-linux-gnu PPA="ppa:bitcoin/bitcoin" PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" SYSCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
# Cross-Mac
Expand Down
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, 3)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_DASH_VERSION_MAJOR, 0)
Expand Down
21 changes: 12 additions & 9 deletions src/assetallocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
#include <boost/algorithm/string.hpp>
#include "thread_pool/thread_pool.hpp"
#include <future>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
using namespace boost::multiprecision;
vector<pair<uint256, int64_t> > vecTPSTestReceivedTimes;
vector<JSONRPCRequest> vecTPSRawTransactions;
int64_t nTPSTestingSendRawElapsedTime = 0;
Expand Down Expand Up @@ -279,12 +281,15 @@ CAmount GetAssetAllocationInterest(CAssetAllocation & assetAllocation, const int
errorMessage = _("Not enough blocks have passed since the last claim, please wait some more time...");
return 0;
}
const int &nInterestBlockTerm = fUnitTest? ONE_HOUR_IN_BLOCKS: ONE_YEAR_IN_BLOCKS;
const int &nBlockDifference = nHeight - assetAllocation.nLastInterestClaimHeight;
const cpp_dec_float_50 &nInterestBlockTerm = fUnitTest ? cpp_dec_float_50(ONE_HOUR_IN_BLOCKS) : cpp_dec_float_50(ONE_YEAR_IN_BLOCKS);
const cpp_dec_float_50 &nBlockDifference = cpp_dec_float_50(nHeight - assetAllocation.nLastInterestClaimHeight);

// apply compound annual interest to get total interest since last time interest was collected
const CAmount& nBalanceOverTimeDifference = assetAllocation.nAccumulatedBalanceSinceLastInterestClaim / nBlockDifference;
const long double& fInterestOverTimeDifference = assetAllocation.fAccumulatedInterestSinceLastInterestClaim / nBlockDifference;
return (((long double)nBalanceOverTimeDifference*powl((1.0 + (fInterestOverTimeDifference / nInterestBlockTerm)), nBlockDifference))) - nBalanceOverTimeDifference;
const cpp_dec_float_50& nBalanceOverTimeDifference = cpp_dec_float_50(assetAllocation.nAccumulatedBalanceSinceLastInterestClaim / nBlockDifference);
const cpp_dec_float_50& fInterestOverTimeDifference = cpp_dec_float_50(assetAllocation.fAccumulatedInterestSinceLastInterestClaim / nBlockDifference);
const cpp_dec_float_50& nInterestPerBlock = fInterestOverTimeDifference / nInterestBlockTerm;
const cpp_dec_float_50& powcalc = (boost::multiprecision::pow(cpp_dec_float_50(1.0) + nInterestPerBlock, nBlockDifference)*nBalanceOverTimeDifference) - nBalanceOverTimeDifference;
return powcalc.convert_to<CAmount>();
}
bool ApplyAssetAllocationInterest(CAsset& asset, CAssetAllocation & assetAllocation, const int& nHeight, string& errorMessage) {
CAmount nInterest = GetAssetAllocationInterest(assetAllocation, nHeight, errorMessage);
Expand Down Expand Up @@ -557,7 +562,7 @@ bool CheckAssetAllocationInputs(const CTransaction &tx, const CCoinsViewCache &i
}
}
const CAmount &nBalanceAfterSend = dbAssetAllocation.nBalance - nTotal;
if (nBalanceAfterSend < -1000) {
if (nBalanceAfterSend < 0) {
bBalanceOverrun = true;
if(bSanityCheck)
errorMessage = "SYSCOIN_ASSET_ALLOCATION_CONSENSUS_ERROR: ERRCODE: 1021 - " + _("Sender balance is insufficient");
Expand Down Expand Up @@ -607,8 +612,6 @@ bool CheckAssetAllocationInputs(const CTransaction &tx, const CCoinsViewCache &i
receiverAllocation.vchMemo = theAssetAllocation.vchMemo;
receiverAllocation.nBalance += amountTuple.second;
theAssetAllocation.nBalance -= amountTuple.second;
if (theAssetAllocation.nBalance < 0)
theAssetAllocation.nBalance = 0;

}
const string& receiverAddress = stringFromVch(receiverAllocation.vchAliasOrAddress);
Expand Down Expand Up @@ -739,7 +742,7 @@ bool CheckAssetAllocationInputs(const CTransaction &tx, const CCoinsViewCache &i
vecTPSTestReceivedTimes.emplace_back(theAssetAllocation.txHash, GetTimeMicros());
}
const string &user = op == OP_ASSET_COLLECT_INTEREST ? user1 : "";
if (!passetallocationdb->WriteAssetAllocation(theAssetAllocation, 0, 0, dbAsset, ms, user, user, fJustCheck))
if (!passetallocationdb->WriteAssetAllocation(theAssetAllocation, theAssetAllocation.nBalance, 0, dbAsset, ms, user, user, fJustCheck))
{
errorMessage = "SYSCOIN_ASSET_ALLOCATION_CONSENSUS_ERROR: ERRCODE: 1031 - " + _("Failed to write to asset allocation DB");
return error(errorMessage.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! These need to be macros, as clientversion.cpp's and syscoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 1
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/


static const int PROTOCOL_VERSION = 70224;
static const int PROTOCOL_VERSION = 70225;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand Down

0 comments on commit 2817bd3

Please sign in to comment.