5 #include <boost/random/uniform_int.hpp>
6 #include <boost/random/mersenne_twister.hpp>
15 int static generateMTRandom(
unsigned int s,
int range)
17 boost::mt19937 gen(s);
18 boost::uniform_int<> dist(1, range);
32 if (pindexLast->
nHeight < 157500)
42 int nHeight = pindexLast->
nHeight + 1;
44 const int64_t nActualTimespan = pindexLast->
GetBlockTime() - nFirstBlockTime;
45 int64_t nModulatedTimespan = nActualTimespan;
52 nModulatedTimespan = retargetTimespan + (nModulatedTimespan - retargetTimespan) / 8;
54 nMinTimespan = retargetTimespan - (retargetTimespan / 4);
55 nMaxTimespan = retargetTimespan + (retargetTimespan / 2);
56 }
else if (nHeight > 10000) {
57 nMinTimespan = retargetTimespan / 4;
58 nMaxTimespan = retargetTimespan * 4;
59 }
else if (nHeight > 5000) {
60 nMinTimespan = retargetTimespan / 8;
61 nMaxTimespan = retargetTimespan * 4;
63 nMinTimespan = retargetTimespan / 16;
64 nMaxTimespan = retargetTimespan * 4;
68 if (nModulatedTimespan < nMinTimespan)
69 nModulatedTimespan = nMinTimespan;
70 else if (nModulatedTimespan > nMaxTimespan)
71 nModulatedTimespan = nMaxTimespan;
79 bnNew *= nModulatedTimespan;
80 bnNew /= retargetTimespan;
82 if (bnNew > bnPowLimit)
95 return error(
"%s : block does not have our chain ID"
96 " (got %d, expected %d, full nVersion %d)",
103 return error(
"%s : no auxpow on block with auxpow version",
107 return error(
"%s : non-AUX proof of work failed", __func__);
115 return error(
"%s : auxpow on block with non-auxpow version", __func__);
118 return error(
"%s : AUX POW is not valid", __func__);
120 return error(
"%s : AUX proof of work failed", __func__);
132 const std::string cseed_str = prevHash.
ToString().substr(7, 7);
133 const char* cseed = cseed_str.c_str();
135 long seed = strtol(cseed, &endp, 16);
136 CAmount maxReward = (1000000 >> halvings) - 1;
137 int rand = generateMTRandom(seed, maxReward);
139 return (1 + rand) * COIN;
142 return (500000 * COIN) >> halvings;
154 double dPriorityDelta = 0;
157 if (dPriorityDelta > 0 || nFeeDelta > 0)
170 if (nBytes < (DEFAULT_BLOCK_PRIORITY_SIZE - 1000))
183 BOOST_FOREACH(
const CTxOut& txout, vout)
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
arith_uint256 UintToArith256(const uint256 &a)
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetBlockTime() const
int nHeight
height of the entry in the chain. The genesis block has height 0
Fee rate in satoshis per kilobyte: CAmount / kB.
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const uint256 & GetHash() const
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta) const
An output of a transaction.
bool IsDust(const CFeeRate &minRelayTxFee) const
256-bit unsigned big integer.
uint32_t GetCompact(bool fNegative=false) const
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=NULL, bool *pfOverflow=NULL)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
std::string ToString() const
CAmount GetDogecoinMinRelayFee(const CTransaction &tx, unsigned int nBytes, bool fAllowFree)
unsigned int CalculateDogecoinNextWorkRequired(const CBlockIndex *pindexLast, int64_t nFirstBlockTime, const Consensus::Params ¶ms)
bool CheckAuxPowProofOfWork(const CBlockHeader &block, const Consensus::Params ¶ms)
Check proof-of-work of a block header, taking auxpow into account.
CAmount GetDogecoinDustFee(const std::vector< CTxOut > &vout, CFeeRate &baseFeeRate)
CAmount GetDogecoinBlockSubsidy(int nHeight, const Consensus::Params &consensusParams, uint256 prevHash)
bool AllowDigishieldMinDifficultyForBlock(const CBlockIndex *pindexLast, const CBlockHeader *pblock, const Consensus::Params ¶ms)
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
Parameters that influence chain consensus.
bool fDigishieldDifficultyCalculation
Dogecoin-specific parameters.
int32_t nAuxpowChainId
Auxpow parameters.
int nSubsidyHalvingInterval
int64_t nPowTargetTimespan
uint256 powLimit
Proof of work parameters.
int64_t nPowTargetSpacing
bool fPowAllowMinDifficultyBlocks
bool error(const char *fmt, const Args &... args)
CTxMemPool mempool(::minRelayTxFee)
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)