Browse Source

coin supply, rewards

pull/4/head
jl777 8 years ago
parent
commit
3a02f67bf3
  1. 2
      src/amount.h
  2. 11
      src/main.cpp
  3. 2
      src/main.h
  4. 4
      src/miner.cpp
  5. 6
      src/rpcmining.cpp
  6. 2
      src/test/compress_tests.cpp

2
src/amount.h

@ -17,7 +17,7 @@ static const CAmount COIN = 100000000;
static const CAmount CENT = 1000000;
/** No amount larger than this (in satoshi) is valid */
static const CAmount MAX_MONEY = 21000000 * COIN;
static const CAmount MAX_MONEY = 200000000 * COIN;
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
/** Type-safe wrapper class to for fee rates

11
src/main.cpp

@ -1367,8 +1367,8 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
CAmount nSubsidy = 12.5 * COIN;
CAmount nSubsidy = 3 * COIN;
/*
// Mining slow start
// The subsidy is ramped up linearly, skipping the middle payout of
// MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start.
@ -1383,8 +1383,9 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
}
assert(nHeight > consensusParams.SubsidySlowStartShift());
int halvings = (nHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nSubsidyHalvingInterval;
int halvings = (nHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nSubsidyHalvingInterval;*/
// Force block reward to zero when right shift is undefined.
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
if (halvings >= 64)
return 0;
@ -3086,7 +3087,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
// Coinbase transaction must include an output sending 20% of
// the block reward to `FOUNDERS_REWARD_SCRIPT` until the first
// subsidy halving block, with exception to the genesis block.
if ((nHeight > 0) && (nHeight < consensusParams.nSubsidyHalvingInterval)) {
/*if ((nHeight > 0) && (nHeight < consensusParams.nSubsidyHalvingInterval)) {
bool found = false;
BOOST_FOREACH(const CTxOut& output, block.vtx[0].vout) {
@ -3101,7 +3102,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
if (!found) {
return state.DoS(100, error("%s: founders reward missing", __func__), REJECT_INVALID, "cb-no-founders-reward");
}
}
}*/
return true;
}

2
src/main.h

@ -48,7 +48,7 @@ class CValidationState;
struct CNodeStateStats;
// This is a 2-of-3 multisig P2SH
static const char *FOUNDERS_REWARD_SCRIPT = "a9146708e6670db0b950dac68031025cc5b63213a49187";
//static const char *FOUNDERS_REWARD_SCRIPT = "a9146708e6670db0b950dac68031025cc5b63213a49187";
/** 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;

4
src/miner.cpp

@ -335,7 +335,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
txNew.vout[0].nValue = GetBlockSubsidy(nHeight, chainparams.GetConsensus());
if ((nHeight > 0) && (nHeight < chainparams.GetConsensus().nSubsidyHalvingInterval)) {
/*if ((nHeight > 0) && (nHeight < chainparams.GetConsensus().nSubsidyHalvingInterval)) {
// Founders reward is 20% of the block subsidy
auto vFoundersReward = txNew.vout[0].nValue / 5;
// Take some reward away from us
@ -346,7 +346,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
// And give it to the founders
txNew.vout.push_back(CTxOut(vFoundersReward, CScript(rewardScript.begin(),
rewardScript.end())));
}
}*/
// Add fees
txNew.vout[0].nValue += nFees;

6
src/rpcmining.cpp

@ -785,13 +785,13 @@ Value getblocksubsidy(const Array& params, bool fHelp)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus());
CAmount nFoundersReward = 0;
/*CAmount nFoundersReward = 0;
if ((nHeight > 0) && (nHeight < Params().GetConsensus().nSubsidyHalvingInterval)) {
nFoundersReward = nReward/5;
nReward -= nFoundersReward;
}
}*/
Object result;
result.push_back(Pair("miner", ValueFromAmount(nReward)));
result.push_back(Pair("founders", ValueFromAmount(nFoundersReward)));
//result.push_back(Pair("founders", ValueFromAmount(nFoundersReward)));
return result;
}

2
src/test/compress_tests.cpp

@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(compress_amounts)
BOOST_CHECK(TestPair( CENT, 0x7));
BOOST_CHECK(TestPair( COIN, 0x9));
BOOST_CHECK(TestPair( 50*COIN, 0x32));
BOOST_CHECK(TestPair(21000000*COIN, 0x1406f40));
BOOST_CHECK(TestPair(MAX_MONEY, 0x1406f40));
for (uint64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++)
BOOST_CHECK(TestEncode(i));

Loading…
Cancel
Save