Merge branch 'randomx' into dev
This commit is contained in:
@@ -1622,13 +1622,13 @@ uint64_t hush_block_subsidy(int height)
|
||||
// wrapper for more general supply curves of Hush Smart Chains
|
||||
uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
{
|
||||
//fprintf(stderr,"%s: ht.%d\n", __func__, nHeight);
|
||||
// Find current era, start from beginning reward, and determine current subsidy
|
||||
int64_t numerator, denominator, subsidy = 0;
|
||||
int64_t subsidyDifference;
|
||||
int32_t numhalvings = 0, curEra = 0, sign = 1;
|
||||
static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era;
|
||||
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
// fprintf(stderr,"%s: ht=%d ishush3=%d\n", __func__, nHeight, ishush3);
|
||||
|
||||
// check for backwards compat, older chains with no explicit rewards had 0.0001 block reward
|
||||
if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) {
|
||||
@@ -1654,6 +1654,9 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
|
||||
if ( subsidy || (curEra != ASSETCHAINS_LASTERA && ASSETCHAINS_REWARD[curEra + 1] != 0) )
|
||||
{
|
||||
if(fDebug) {
|
||||
fprintf(stderr,"%s: subsidy=%ld at height=%d with ASSETCHAINS_HALVING[curEra]=%lu\n",__func__,subsidy,nHeight, ASSETCHAINS_HALVING[curEra]);
|
||||
}
|
||||
if ( ASSETCHAINS_HALVING[curEra] != 0 )
|
||||
{
|
||||
if (ishush3) {
|
||||
@@ -1664,7 +1667,7 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
// The code below is not compatible with HUSH3 mainnet
|
||||
if ( ASSETCHAINS_DECAY[curEra] == 0 ) {
|
||||
subsidy >>= numhalvings;
|
||||
fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld nStart.%ld\n",__func__, numhalvings, curEra, subsidy, nStart);
|
||||
// fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld nStart.%ld\n",__func__, numhalvings, curEra, subsidy, nStart);
|
||||
} else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) {
|
||||
if ( curEra == ASSETCHAINS_LASTERA )
|
||||
{
|
||||
@@ -1680,7 +1683,14 @@ uint64_t hush_sc_block_subsidy(int nHeight)
|
||||
}
|
||||
denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart;
|
||||
numerator = denominator - ((ASSETCHAINS_ENDSUBSIDY[curEra] - nHeight) + ((nHeight - nStart) % ASSETCHAINS_HALVING[curEra]));
|
||||
subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator);
|
||||
// fprintf(stderr,"%s: numerator=%ld , denominator=%ld at height=%d\n",__func__,numerator, denominator,nHeight);
|
||||
if( denominator ) {
|
||||
subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator);
|
||||
} else {
|
||||
fprintf(stderr,"%s: invalid denominator=%ld !\n", __func__, denominator);
|
||||
fprintf(stderr,"%s: defaulting to 0.0001 subsidy\n",__func__);
|
||||
subsidy = 10000;
|
||||
}
|
||||
} else {
|
||||
if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) {
|
||||
subsidy = cached_subsidy;
|
||||
|
||||
Reference in New Issue
Block a user