Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 21 additions & 68 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,17 @@ double ConvertBitsToDouble(unsigned int nBits)
int64_t GetBlockValue(int nHeight)
{
int64_t nSubsidy = 0;

if(Params().NetworkID() == CBaseChainParams::TESTNET)
{
if(nHeight < 200 && nHeight > 0)
return 250000 * COIN;

// Add TESTNET_OFFSET to nheight because that is the current height at time of writing this code
// This will allow the testnet simulation to catch up to current main net conditions
nHeight += TESTNET_OFFSET;
}

if(nHeight == 0) {
nSubsidy = 60001 * COIN;
}
Expand Down Expand Up @@ -1681,21 +1692,23 @@ int64_t GetBlockValue(int nHeight)
else {
nSubsidy = 0 * COIN;
}
if(Params().NetworkID() == CBaseChainParams::TESTNET){
if(nHeight < 200 && nHeight > 0) {
nSubsidy = 25000 * COIN;
}
else {
nSubsidy = 50 * COIN;
}
}
return nSubsidy;
}

int64_t GetMasternodePayment(int nHeight, int64_t blockValue)
{
int64_t ret = 0;

if(Params().NetworkID() == CBaseChainParams::TESTNET)
{
if(nHeight < 200)
return 0;

// Add TESTNET_OFFSET to nheight because that is the current height at time of writing this code
// This will allow the testnet simulation to catch up to current main net conditions
nHeight += TESTNET_OFFSET;
}

if(nHeight <= 43200) {
ret = blockValue/5;
}
Expand Down Expand Up @@ -2031,66 +2044,6 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue)
}
}
}
if(Params().NetworkID() == CBaseChainParams::TESTNET){
int64_t nMoneySupply = chainActive.Tip()->nMoneySupply;
int64_t mNodeCoins = mnodeman.size() * 10000 * COIN;

if(fDebug)
LogPrintf("GetMasternodePayment(): moneysupply=%s, nodecoins=%s \n", FormatMoney(nMoneySupply).c_str(),
FormatMoney(mNodeCoins).c_str());

if (mNodeCoins == 0) {
ret = 0;
}
else if (mNodeCoins <= (nMoneySupply * .05) && mNodeCoins > 0) {
ret = blockValue * .85;
}
else if (mNodeCoins <= (nMoneySupply * .1) && mNodeCoins > (nMoneySupply * .05)) {
ret = blockValue * .8;
}
else if (mNodeCoins <= (nMoneySupply * .15) && mNodeCoins > (nMoneySupply * .1)) {
ret = blockValue * .75;
}
else if (mNodeCoins <= (nMoneySupply * .2) && mNodeCoins > (nMoneySupply * .15)) {
ret = blockValue * .7;
}
else if (mNodeCoins <= (nMoneySupply * .25) && mNodeCoins > (nMoneySupply * .2)) {
ret = blockValue * .65;
}
else if (mNodeCoins <= (nMoneySupply * .3) && mNodeCoins > (nMoneySupply * .25)) {
ret = blockValue * .6;
}
else if (mNodeCoins <= (nMoneySupply * .35) && mNodeCoins > (nMoneySupply * .3)) {
ret = blockValue * .55;
}
else if (mNodeCoins <= (nMoneySupply * .4) && mNodeCoins > (nMoneySupply * .35)) {
ret = blockValue * .5;
}
else if (mNodeCoins <= (nMoneySupply * .45) && mNodeCoins > (nMoneySupply * .4)) {
ret = blockValue * .45;
}
else if (mNodeCoins <= (nMoneySupply * .5) && mNodeCoins > (nMoneySupply * .45)) {
ret = blockValue * .4;
}
else if (mNodeCoins <= (nMoneySupply * .55) && mNodeCoins > (nMoneySupply * .5)) {
ret = blockValue * .35;
}
else if (mNodeCoins <= (nMoneySupply * .6) && mNodeCoins > (nMoneySupply * .55)) {
ret = blockValue * .3;
}
else if (mNodeCoins <= (nMoneySupply * .65) && mNodeCoins > (nMoneySupply * .6)) {
ret = blockValue * .25;
}
else if (mNodeCoins <= (nMoneySupply * .7) && mNodeCoins > (nMoneySupply * .65)) {
ret = blockValue * .2;
}
else if (mNodeCoins <= (nMoneySupply * .75) && mNodeCoins > (nMoneySupply * .7)) {
ret = blockValue * .15;
}
else{
ret = blockValue * .1;
}
}

return ret;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class CValidationState;

struct CBlockTemplate;
struct CNodeStateStats;


/** Allow testnet to catch up to mainnet */
static const int TESTNET_OFFSET = 436126;
/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
Expand Down
29 changes: 23 additions & 6 deletions src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,31 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, b

if(fProofOfStake) {
if(nHighestCount > 0) {
unsigned int i = txNew.vout.size();
txNew.vout.resize(i + 1);
txNew.vout[i].scriptPubKey = payee;
txNew.vout[i].nValue = nAmount;
if (Params().NetworkID() == CBaseChainParams::TESTNET)
{
// Test for superblock-issue.
LogPrintf("CBudgetManager::FillBlockPayee - txNew.vout.size() = %d\n", txNew.vout.size());

txNew.vout[0].nValue = blockValue;

//stakers get the full amount on these blocks
txNew.vout[i - 1].nValue = blockValue;
txNew.vout.resize(2);

// these are super blocks, so their value can be much larger than normal
txNew.vout[1].scriptPubKey = payee;
txNew.vout[1].nValue = nAmount;
}
else
{
// Current mainnet logic. Can be changed when testnet runs okay
unsigned int i = txNew.vout.size();
txNew.vout.resize(i + 1);
txNew.vout[i].scriptPubKey = payee;
txNew.vout[i].nValue = nAmount;

//stakers get the full amount on these blocks
txNew.vout[i - 1].nValue = blockValue;
}

CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
Expand Down
4 changes: 2 additions & 2 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe
CAmount blockValue = GetBlockValue(pindexPrev->nHeight);
CAmount masternodePayment = GetMasternodePayment(pindexPrev->nHeight, blockValue);


txNew.vout[0].nValue = blockValue;

if(hasPayment)
{
Expand All @@ -331,7 +331,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe
txNew.vout.resize(2);
txNew.vout[1].scriptPubKey = payee;
txNew.vout[1].nValue = masternodePayment;
txNew.vout[0].nValue = blockValue - masternodePayment;
txNew.vout[0].nValue -= masternodePayment;
}

CTxDestination address1;
Expand Down
36 changes: 20 additions & 16 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
CValidationState state;
if (!TestBlockValidity(state, *pblock, pindexPrev, false, false))
{
LogPrintf("CreateNewBlock() : TestBlockValidity failed");
LogPrintf("CreateNewBlock() : TestBlockValidity failed\n");
return NULL;
}
}
Expand Down Expand Up @@ -465,6 +465,7 @@ bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
bool fGenerateBitcoins = false;

// ***TODO*** that part changed in bitcoin, we are using a mix with old one here for now

void BitcoinMiner(CWallet *pwallet, bool fProofOfStake)
{
LogPrintf("DarkNetMiner started\n");
Expand All @@ -487,26 +488,29 @@ void BitcoinMiner(CWallet *pwallet, bool fProofOfStake)

while (fGenerateBitcoins || fProofOfStake)
{
if(chainActive.Tip()->nHeight < Params().LAST_POW_BLOCK())
{
MilliSleep(5000);
continue;
}

while (chainActive.Tip()->nTime < 1471482000 || vNodes.empty() || pwallet->IsLocked() || !fMintableCoins || nReserveBalance >= pwallet->GetBalance() || !masternodeSync.IsSynced())
if(fProofOfStake)
{
nLastCoinStakeSearchInterval = 0;
MilliSleep(5000);
if (!fGenerateBitcoins && !fProofOfStake)
if(chainActive.Tip()->nHeight < Params().LAST_POW_BLOCK())
{
MilliSleep(5000);
continue;
}
}

if(mapHashedBlocks.count(chainActive.Tip()->nHeight)) //search our map of hashed blocks, see if bestblock has been hashed yet
{
if(GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < max(pwallet->nHashInterval, (unsigned int)1)) // wait half of the nHashDrift with max wait of 3 minutes
while (chainActive.Tip()->nTime < 1471482000 /*|| vNodes.empty()*/ || pwallet->IsLocked() || !fMintableCoins || nReserveBalance >= pwallet->GetBalance() /*|| !masternodeSync.IsSynced()*/)
{
nLastCoinStakeSearchInterval = 0;
MilliSleep(5000);
continue;
if (!fGenerateBitcoins && !fProofOfStake)
continue;
}

if(mapHashedBlocks.count(chainActive.Tip()->nHeight)) //search our map of hashed blocks, see if bestblock has been hashed yet
{
if(GetTime() - mapHashedBlocks[chainActive.Tip()->nHeight] < max(pwallet->nHashInterval, (unsigned int)1)) // wait half of the nHashDrift with max wait of 3 minutes
{
MilliSleep(5000);
continue;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
bool fOverflow;
uint256 bnTarget;

if (Params().SkipProofOfWorkCheck())
if (Params().SkipProofOfWorkCheck() || Params().NetworkID() == CBaseChainParams::TESTNET)
return true;

bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
Expand All @@ -120,7 +120,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
return error("CheckProofOfWork() : nBits below minimum work");

// Check proof of work matches claimed amount
if (hash > bnTarget)
if (hash > bnTarget && Params().NetworkID() != CBaseChainParams::TESTNET)
return error("CheckProofOfWork() : hash doesn't match nBits");

return true;
Expand Down