Skip to content

Commit

Permalink
PoS Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NXEProtocol committed Feb 12, 2015
1 parent 400339a commit 4ee0fef
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DKC-qt.pro → DarkCredit-qt.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = DarkCredit-qt
VERSION = 2.0.0
VERSION = 1.0.2
INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
Expand Down
1 change: 1 addition & 0 deletions src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace Checkpoints
( 250, uint256("0x0000000005aeb9c009ecea2bb2d17086215a934636e2c934313ec45ef55f04a0"))
( 1400, uint256("0x00000000021d00cc636b96b517c5bd2124eef7851761f4e15b759816df2ab161"))
( 2000, uint256("0x00000000020387760aaf66d56929b6f1162586309524d96be6a8dddc29ff5707"))
( 3888, uint256("0x0000000005f00e8113651a79e250ec0369db84e85d18b74710bb9ce99e79a1f5"))
;

// TestNet has no checkpoints
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 0

// Converts the parameter X to a string after macro replacement on X has been performed.
Expand Down
11 changes: 9 additions & 2 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,16 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned

uint256 hashBlockFrom = blockFrom.GetHash();

CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60);
targetProofOfStake = (bnCoinDayWeight * bnTargetPerCoinDay).getuint256();
//CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60);
CBigNum bnCoinDayWeight;
if (nTimeTx > STAKEFORKTIME)
bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / MILLICOIN / (24 * 60 * 60);
else
bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / (24 * 60 * 60);


targetProofOfStake = (bnCoinDayWeight * bnTargetPerCoinDay).getuint256();

// Calculate hash
CDataStream ss(SER_GETHASH, 0);
uint64_t nStakeModifier = 0;
Expand Down
1 change: 1 addition & 0 deletions src/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define PPCOIN_KERNEL_H

#include "main.h"
#define STAKEFORKTIME 1423781197

// MODIFIER_INTERVAL: time to elapse before new modifier is computed
extern unsigned int nModifierInterval;
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static const int64_t MIN_RELAY_TX_FEE = MIN_TX_FEE;
static const int64_t MAX_MONEY = 5000000 * COIN; //Does not reflect actual total DarkCredits made.
static const int64_t COIN_YEAR_REWARD = 0.12 * CENT; // 12% per year
static const int64_t MAX_MINT_PROOF_OF_STAKE = 0.12 * COIN; // 12% Annual PoS Interest
static const int MODIFIER_INTERVAL_SWITCH = 15000;
static const int MODIFIER_INTERVAL_SWITCH = 200;

inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
// Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp.
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ void MapPort()
// The second name should resolve to a list of seed addresses.

static const char *strDNSSeed[][2] = {
{"darkcredit.net", "node.darkcredit.net"}, //Main DarkCredit Seed Node
{"darkcredit.net", "dkcnode3.ddns.net"}, //Main DarkCredit Seed Node
{"dkcnode.ddns.net", "dkcnode2.ddns.net"}, //BackUp DarkCredit Seed Node
};

Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

static const int64_t COIN = 100000000;
static const int64_t CENT = 1000000;
static const int64_t MILLICOIN = 100000;

#define BEGIN(a) ((char*)&(a))
#define END(a) ((char*)&((&(a))[1]))
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ extern const std::string CLIENT_DATE;
//
// database format versioning
//
static const int DATABASE_VERSION = 100050;
static const int DATABASE_VERSION = 100055;

//
// network protocol versioning
//

static const int PROTOCOL_VERSION = 100050;
static const int PROTOCOL_VERSION = 100055;

// intial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand Down
13 changes: 12 additions & 1 deletion src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,10 @@ bool CWallet::FindStealthTransactions(const CTransaction& tx, mapValue_t& mapNar
// NovaCoin: get current stake weight
bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64_t& nMinWeight, uint64_t& nMaxWeight, uint64_t& nWeight)
{
printf("GetStakeWeight : ForkTime = %li\n",STAKEFORKTIME);
printf("GetStakeWeight: %s\n", DateTimeStrFormat("%x %H:%M:%S", STAKEFORKTIME).c_str());
printf("GetStakeWeight : GetTime = %li\n",GetTime());
printf("GetStakeWeight: %s\n", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
// Choose coins to use
int64_t nBalance = GetBalance();

Expand Down Expand Up @@ -2371,8 +2375,13 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64_t& nMinWeight, ui
}

int64_t nTimeWeight = GetWeight((int64_t)pcoin.first->nTime, (int64_t)GetTime());
CBigNum bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60);
//CBigNum bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60);

CBigNum bnCoinDayWeight;
if (GetTime() > STAKEFORKTIME)
bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / MILLICOIN / (24 * 60 * 60);
else
bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60);
// Weight is greater than zero
if (nTimeWeight > 0)
{
Expand All @@ -2392,6 +2401,8 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64_t& nMinWeight, ui
}
}

printf("GetStakeWeight : nWeight = %lu\n",nWeight);

return true;
}

Expand Down

0 comments on commit 4ee0fef

Please sign in to comment.