Added DarkGravityWave (DGW), Hard fork at 34140!

This commit is contained in:
Evan 2014-03-14 19:56:19 -07:00
parent bd593e75f8
commit 07c99052ed
5 changed files with 116 additions and 36 deletions

View File

@ -11,14 +11,12 @@ What is DarkCoin?
DarkCoin is a lite version of Bitcoin using X11 as a proof-of-work algorithm.
- Super secure hashing algorithm: 11 rounds of scientific hashing functions (blake, bmw, groestl, jh, keccak, skein, luffa, cubehash, shavite, simd, echo)
- Block reward is controlled by moore's law: (11111 / (((Difficulty+51)/6) ^ 2))
- CPU only mining
- Block reward is controlled by moore's law: 2222222/(((Difficulty+2600)/9)^2)
- GPU/CPU only mining
- Block generation: 2.5 minutes
- Difficulty Retargets every 576 blocks
- 84 Million Coins Max
- Block reward halving every 2 years
- Encrypted transaction network: Work In Progress
- Anonymous blockchain using coinjoin technology: Work In Progress
- Difficulty Retargets every block using Dark Gravity Wave
- Est. ~7M Coins in 2015, ~13M in 2020, ~23M in 2030
- Anonymous blockchain using DarkSend technology (Based on CoinJoin): Beta Testing
For more information, as well as an immediately useable, binary version of
the DarkCoin client sofware, see http://www.darkcoin.io.

View File

@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = darkcoin-qt
macx:TARGET = "DarkCoin-Qt"
VERSION = 0.8.9.0
VERSION = 0.9.0.0
INCLUDEPATH += src src/json src/qt
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

View File

@ -5,8 +5,8 @@ SetCompressor /SOLID lzma
# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 0.8.9.0
!define COMPANY "DarkCoin project"
!define VERSION 0.9.0.0
!define URL http://www.darkcoin.io/
# MUI Symbol Definitions
@ -45,13 +45,13 @@ Var StartMenuGroup
!insertmacro MUI_LANGUAGE English
# Installer attributes
OutFile darkcoin-0.8.0.0-win32-setup.exe
OutFile darkcoin-0.9.0.0-win32-setup.exe
InstallDir $PROGRAMFILES\DarkCoin
CRCCheck on
XPStyle on
BrandingText " "
ShowInstDetails show
VIProductVersion 0.8.9.0
VIProductVersion 0.9.0.0
VIAddVersionKey ProductName DarkCoin
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"

View File

@ -7,8 +7,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 8
#define CLIENT_VERSION_REVISION 9
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build

View File

@ -918,6 +918,26 @@ int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet) const
}
double ConvertBitsToDouble(unsigned int nBits){
int nShift = (nBits >> 24) & 0xff;
double dDiff =
(double)0x0000ffff / (double)(nBits & 0x00ffffff);
while (nShift < 29)
{
dDiff *= 256.0;
nShift++;
}
while (nShift > 29)
{
dDiff /= 256.0;
nShift--;
}
return dDiff;
}
int CMerkleTx::GetBlocksToMaturity() const
{
if (!IsCoinBase())
@ -1064,24 +1084,11 @@ uint256 static GetOrphanRoot(const CBlockHeader* pblock)
int64 static GetBlockValue(int nBits, int nHeight, int64 nFees)
{
int nShift = (nBits >> 24) & 0xff;
double dDiff =
(double)0x0000ffff / (double)(nBits & 0x00ffffff);
/* fixed bug caused diff to not be correctly calculated */
if(nHeight > 4500) {
while (nShift < 29)
{
dDiff *= 256.0;
nShift++;
}
while (nShift > 29)
{
dDiff /= 256.0;
nShift--;
}
}
if(nHeight > 4500) dDiff = ConvertBitsToDouble(nBits);
int64 nSubsidy = 0;
if(nHeight >= 5465) {
@ -1206,7 +1213,6 @@ unsigned int static GetNextWorkRequired_V1(const CBlockIndex* pindexLast, const
}
unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBlockHeader *pblock, uint64 TargetBlocksSpacingSeconds, uint64 PastBlocksMin, uint64 PastBlocksMax) {
/* current difficulty formula, megacoin - kimoto gravity well */
const CBlockIndex *BlockLastSolved = pindexLast;
const CBlockIndex *BlockReading = pindexLast;
const CBlockHeader *BlockCreating = pblock;
@ -1254,11 +1260,88 @@ unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBloc
bnNew *= PastRateActualSeconds;
bnNew /= PastRateTargetSeconds;
}
if (bnNew > bnProofOfWorkLimit) { bnNew = bnProofOfWorkLimit; }
if (bnNew > bnProofOfWorkLimit) {
bnNew = bnProofOfWorkLimit;
}
return bnNew.GetCompact();
}
unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
/* current difficulty formula, darkcoin - DarkGravity, 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(Diff < 0) Diff = 0;
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 = (((nBlockTimeAverage)*0.7)+((nBlockTimeSum2 / nBlockTimeCount2)*0.3));
if(SmartAverage < 1) SmartAverage = 1;
double Shift = nTargetSpacing/SmartAverage;
int64 nActualTimespan = (CountBlocks*nTargetSpacing)/Shift;
int64 nTargetTimespan = (CountBlocks*nTargetSpacing);
if (nActualTimespan < nTargetTimespan/3)
nActualTimespan = nTargetTimespan/3;
if (nActualTimespan > nTargetTimespan*3)
nActualTimespan = nTargetTimespan*3;
// Retarget
bnNew *= nActualTimespan;
bnNew /= nTargetTimespan;
}
if (bnNew > bnProofOfWorkLimit){
bnNew = bnProofOfWorkLimit;
}
return bnNew.GetCompact();
}
unsigned int static GetNextWorkRequired_V2(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
@ -1272,20 +1355,21 @@ unsigned int static GetNextWorkRequired_V2(const CBlockIndex* pindexLast, const
return KimotoGravityWell(pindexLast, pblock, BlocksTargetSpacing, PastBlocksMin, PastBlocksMax);
}
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
int DiffMode = 1;
if (fTestNet) {
if (pindexLast->nHeight+1 >= 10) { DiffMode = 2; }
if (pindexLast->nHeight+1 >= 5) { 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); }
return GetNextWorkRequired_V2(pindexLast, pblock);
else if (DiffMode == 3) { return DarkGravityWave(pindexLast, pblock); }
return DarkGravityWave(pindexLast, pblock);
}
@ -4527,8 +4611,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nLastBlockSize = nBlockSize;
printf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize);
float dDiff =
(float)0x0000ffff / (float)(pindexPrev->nBits & 0x00ffffff);
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nBits, pindexPrev->nHeight, nFees);
pblocktemplate->vTxFees[0] = -nFees;