updated to master, version bump

This commit is contained in:
Evan Duffield 2014-07-18 08:46:29 -07:00
parent cf0e542d70
commit d4409103d3
6 changed files with 47 additions and 157 deletions

6
.gitignore vendored
View File

@ -15,7 +15,7 @@ src/test_darkcoin
*.qm
Makefile
darkcoin-qt
darkcoin-Qt.app
DarkCoin-Qt.app
# Unit-tests
Makefile.test
@ -32,4 +32,6 @@ qrc_*.cpp
build
!src/leveldb-*/Makefile
src/sendmonies.sh
.cproject
.project

View File

@ -50,7 +50,7 @@ namespace Checkpoints
;
static const CCheckpointData data = {
&mapCheckpoints,
1401126238, // * UNIX timestamp of last checkpoint block
1403283082, // * UNIX timestamp of last checkpoint block
25000, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
800.0 // * estimated number of transactions per day after checkpoint

View File

@ -8,8 +8,8 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 10
#define CLIENT_VERSION_REVISION 11
#define CLIENT_VERSION_BUILD 5
#define CLIENT_VERSION_REVISION 12
#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true

View File

@ -64,8 +64,10 @@ std::vector<CMasterNodeVote> darkSendMasterNodeVotes;
std::vector<int64> darkSendDenominations;
std::vector<pair<int64, pair<CTxIn, int> > > vecBlockVotes;
std::vector<pair<int64, CTxIn> > vecMasternodesVoted;
std::vector<CTxIn> vecMasternodeAskedFor;
int64 enforceMasternodePaymentsTime = 4085657524;
std::vector<CTxIn> vecMasternodeAskedFor;
/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
int64 CTransaction::nMinTxFee = 100000;
@ -1513,83 +1515,6 @@ unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBloc
return bnNew.GetCompact();
}
unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
/* current difficulty formula, darkcoin - DarkGravity v2, written by Evan Duffield - evan@darkcoin.io */
const CBlockIndex *BlockLastSolved = pindexLast;
const CBlockIndex *BlockReading = pindexLast;
const CBlockHeader *BlockCreating = pblock;
BlockCreating = BlockCreating;
int64 nBlockTimeAverage = 0;
int64 nBlockTimeAveragePrev = 0;
int64 nBlockTimeCount = 0;
int64 nBlockTimeSum2 = 0;
int64 nBlockTimeCount2 = 0;
int64 LastBlockTime = 0;
int64 PastBlocksMin = 14;
int64 PastBlocksMax = 140;
int64 CountBlocks = 0;
CBigNum PastDifficultyAverage;
CBigNum PastDifficultyAveragePrev;
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || BlockLastSolved->nHeight < PastBlocksMin) { return bnProofOfWorkLimit.GetCompact(); }
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
if (PastBlocksMax > 0 && i > PastBlocksMax) { break; }
CountBlocks++;
if(CountBlocks <= PastBlocksMin) {
if (CountBlocks == 1) { PastDifficultyAverage.SetCompact(BlockReading->nBits); }
else { PastDifficultyAverage = ((CBigNum().SetCompact(BlockReading->nBits) - PastDifficultyAveragePrev) / CountBlocks) + PastDifficultyAveragePrev; }
PastDifficultyAveragePrev = PastDifficultyAverage;
}
if(LastBlockTime > 0){
int64 Diff = (LastBlockTime - BlockReading->GetBlockTime());
if(nBlockTimeCount <= PastBlocksMin) {
nBlockTimeCount++;
if (nBlockTimeCount == 1) { nBlockTimeAverage = Diff; }
else { nBlockTimeAverage = ((Diff - nBlockTimeAveragePrev) / nBlockTimeCount) + nBlockTimeAveragePrev; }
nBlockTimeAveragePrev = nBlockTimeAverage;
}
nBlockTimeCount2++;
nBlockTimeSum2 += Diff;
}
LastBlockTime = BlockReading->GetBlockTime();
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
BlockReading = BlockReading->pprev;
}
CBigNum bnNew(PastDifficultyAverage);
if (nBlockTimeCount != 0 && nBlockTimeCount2 != 0) {
double SmartAverage = ((((long double)nBlockTimeAverage)*0.7)+(((long double)nBlockTimeSum2 / (long double)nBlockTimeCount2)*0.3));
if(SmartAverage < 1) SmartAverage = 1;
double Shift = nTargetSpacing/SmartAverage;
double fActualTimespan = ((long double)CountBlocks*(double)nTargetSpacing)/Shift;
double fTargetTimespan = ((long double)CountBlocks*(double)nTargetSpacing);
if (fActualTimespan < fTargetTimespan/3)
fActualTimespan = fTargetTimespan/3;
if (fActualTimespan > fTargetTimespan*3)
fActualTimespan = fTargetTimespan*3;
int64 nActualTimespan = fActualTimespan;
int64 nTargetTimespan = fTargetTimespan;
// Retarget
bnNew *= nActualTimespan;
bnNew /= nTargetTimespan;
}
if (bnNew > bnProofOfWorkLimit){
bnNew = bnProofOfWorkLimit;
}
return bnNew.GetCompact();
}
unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
/* current difficulty formula, darkcoin - DarkGravity v3, written by Evan Duffield - evan@darkcoin.io */
const CBlockIndex *BlockLastSolved = pindexLast;
@ -1663,24 +1588,21 @@ unsigned int static GetNextWorkRequired_V2(const CBlockIndex* pindexLast, const
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
int DiffMode = 1;
if (fTestNet) {
if (pindexLast->nHeight+1 >= 160) { DiffMode = 4; }
if (pindexLast->nHeight+1 >= 256) DiffMode = 3;
}
else {
if (pindexLast->nHeight+1 >= 68589) { DiffMode = 4; }
else if (pindexLast->nHeight+1 >= 34140) { DiffMode = 3; }
else if (pindexLast->nHeight+1 >= 15200) { DiffMode = 2; }
if (pindexLast->nHeight+1 >= 34140) DiffMode = 3;
else if (pindexLast->nHeight+1 >= 15200) DiffMode = 2;
}
if (DiffMode == 1) { return GetNextWorkRequired_V1(pindexLast, pblock); }
else if (DiffMode == 2) { return GetNextWorkRequired_V2(pindexLast, pblock); }
else if (DiffMode == 3) { return DarkGravityWave(pindexLast, pblock); }
else if (DiffMode == 4) { return DarkGravityWave3(pindexLast, pblock); }
else if (DiffMode == 3) { return DarkGravityWave3(pindexLast, pblock); }
return DarkGravityWave3(pindexLast, pblock);
}
bool CheckProofOfWork(uint256 hash, unsigned int nBits)
{
CBigNum bnTarget;
@ -1814,33 +1736,6 @@ uint256 CBlockHeader::GetHash() const
return Hash9(BEGIN(nVersion), END(nNonce));
}
uint256 CBlockHeader::GetSpecialHash() const
{
// calculate additional masternode vote info to include in hash
uint256 hash = 0;
uint256 vmnAdditional = 0;
//printf("------------------------------------------------\n");
if( (fTestNet && nTime > START_MASTERNODE_PAYMENTS_TESTNET) || (!fTestNet && nTime > START_MASTERNODE_PAYMENTS)) {
BOOST_FOREACH(CMasterNodeVote mv1, vmn){
uint160 n2 = mv1.pubkey.GetID();
uint256 n = 0;
memcpy(&n, &n2, sizeof(n2));
//printf(" vmnAdd1 %s\n", n.GetHex().c_str());
vmnAdditional += n;
//printf(" vmnAdd2 %s\n", vmnAdditional.GetHex().c_str());
vmnAdditional <<= (mv1.votes*8) + (mv1.blockHeight % 64);
//printf(" vmnAdd3 %s\n", vmnAdditional.GetHex().c_str());
}
hash = Hash9(BEGIN(nVersion), END(nNonce));
return Hash9(BEGIN(hash), END(vmnAdditional));
};
return Hash9(BEGIN(nVersion), END(nNonce));
}
const CTxOut &CTransaction::GetOutputFor(const CTxIn& input, CCoinsViewCache& view)
{
const CCoins &coins = view.GetCoins(input.prevout.hash);
@ -5934,7 +5829,6 @@ public:
/* *** BEGIN DARKSEND MAGIC - DARKCOIN **********
Copyright 2014, Darkcoin Developers
eduffield - evan@darkcoin.io
InternetApe - kyle@darkcoin.io
*/

View File

@ -94,7 +94,7 @@ static const int64 DUST_SOFT_LIMIT = 100000; // 0.001 DRK
/** Dust Hard Limit, ignored as wallet inputs (mininput default) */
static const int64 DUST_HARD_LIMIT = 1000; // 0.00001 DRK mininput
/** No amount larger than this (in satoshi) is valid */
static const int64 MAX_MONEY = 84000000 * COIN;
static const int64 MAX_MONEY = 22000000 * COIN;
inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
static const int COINBASE_MATURITY = 100;
@ -1454,7 +1454,6 @@ public:
}
uint256 GetHash() const;
uint256 GetSpecialHash() const;
int64 GetBlockTime() const
{

View File

@ -5,45 +5,9 @@
#include "base58.h"
#include "util.h"
#include "main.h"
#include "key.h"
#include "wallet.h"
using namespace std;
typedef set<pair<const CWalletTx*,unsigned int> > CoinSet;
static CWallet wallet;
static std::vector<CTxIn> vCoins;
static void add_coin(int64 nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
{
static int nextLockTime = 0;
CTransaction tx;
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
tx.vout.resize(nInput+1);
tx.vout[nInput].nValue = nValue;
CWalletTx* wtx = new CWalletTx(&wallet, tx);
if (fIsFromMe)
{
// IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(),
// so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
wtx->vin.resize(1);
wtx->fDebitCached = true;
wtx->nDebitCached = 1;
}
COutput output(wtx, nInput, nAge);
vCoins.push_back(output);
}
static void empty_wallet(void)
{
BOOST_FOREACH(COutput output, vCoins)
delete output.tx;
vCoins.clear();
}
BOOST_AUTO_TEST_SUITE(darksend_tests)
BOOST_AUTO_TEST_CASE(darksend_sign)
@ -73,6 +37,37 @@ BOOST_AUTO_TEST_CASE(darksend_vote)
BOOST_CHECK(mnv.GetVotes() == 3);
}
BOOST_AUTO_TEST_CASE(set_collateral_address_bad)
{
CDarkSendPool * dsp_ptr = new CDarkSendPool();
string crappy = "badaddress";
BOOST_CHECK( dsp_ptr->SetCollateralAddress(crappy) == false );
delete dsp_ptr;
}
BOOST_AUTO_TEST_CASE(set_collateral_address_production)
{
CDarkSendPool * dsp_ptr = new CDarkSendPool();
string prod = "Xq19GqFvajRrEdDHYRKGYjTsQfpV5jyipF";
BOOST_CHECK( dsp_ptr->SetCollateralAddress(prod) == true );
delete dsp_ptr;
}
BOOST_AUTO_TEST_CASE(set_collateral_address_testnet)
{
CDarkSendPool * dsp_ptr = new CDarkSendPool();
string testnet = "mxE2Rp3oYpSEFdsN5TdHWhZvEHm3PJQQVm";
BOOST_CHECK( dsp_ptr->SetCollateralAddress(testnet) == true );
delete dsp_ptr;
}
BOOST_AUTO_TEST_CASE(darksend_masternode_voting)
{
uint256 n1 = 10000;