Browse Source

Behold vast logspam, refactoring and dead code removal

pull/136/head
Duke Leto 4 years ago
parent
commit
807a37e740
  1. 5
      src/komodo_bitcoind.h
  2. 29
      src/komodo_utils.h
  3. 15
      src/main.cpp

5
src/komodo_bitcoind.h

@ -1240,18 +1240,20 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
// or start your own Hush Smart Chain: https://github.com/myhush/hush-smart-chains
uint64_t komodo_commission(const CBlock *pblock,int32_t height)
{
fprintf(stderr,"%s at height=%d\n",__func__,height);
static bool didinit = false, ishush3 = false;
if (!didinit) {
ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false;
didinit = true;
fprintf(stderr,"%s: didinit ishush3=%d\n", __func__, ishush3);
}
int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0;
if ( ASSETCHAINS_FOUNDERS != 0 )
{
nSubsidy = GetBlockSubsidy(height,Params().GetConsensus());
//fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION));
fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION));
commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN);
// Do not change this code unless you really know what you are doing.
@ -1997,6 +1999,7 @@ void GetKomodoEarlytxidScriptPub()
int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
{
fprintf(stderr,"%s at height=%d\n",__func__,height);
int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false;
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 )
{

29
src/komodo_utils.h

@ -1548,10 +1548,9 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era;
// check for backwards compat, older chains with no explicit rewards had 0.0001 block reward
if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 )
if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) {
subsidy = 10000;
else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 )
{
} else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) {
// if we have an end block in the first era, find our current era
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 )
{
@ -1571,16 +1570,14 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
{
if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 )
{
if ( ASSETCHAINS_DECAY[curEra] == 0 )
if ( ASSETCHAINS_DECAY[curEra] == 0 ) {
subsidy >>= numhalvings;
else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 )
{
fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld\n",__func__, numhalvings, curEra, subsidy);
} else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) {
if ( curEra == ASSETCHAINS_LASTERA )
{
subsidyDifference = subsidy;
}
else
{
} else {
// Ex: -ac_eras=3 -ac_reward=0,384,24 -ac_end=1440,260640,0 -ac_halving=1,1440,2103840 -ac_decay 100000000,97750000,0
subsidyDifference = subsidy - ASSETCHAINS_REWARD[curEra + 1];
if (subsidyDifference < 0)
@ -1592,13 +1589,10 @@ uint64_t komodo_ac_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);
}
else
{
if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings )
} else {
if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) {
subsidy = cached_subsidy;
else
{
} else {
for (int i=0; i < numhalvings && subsidy != 0; i++)
subsidy = (subsidy * ASSETCHAINS_DECAY[curEra]) / 100000000;
cached_subsidy = subsidy;
@ -1614,6 +1608,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff);
if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion?
{
fprintf(stderr,"%s: Detected supply over 10 billion, danger zone!\n",__func__);
if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 )
{
subsidy += (uint64_t)1000000000 * COIN;
@ -1628,9 +1623,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
else
subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra;
}
else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 )
return(0);
// LABS fungible chains, cannot have any block reward!
fprintf(stderr,"%s: ht.%d curEra.%d subsidy.%ld numhalvings.%d\n",__func__,nHeight,curEra,subsidy,numhalvings);
return(subsidy);
}

15
src/main.cpp

@ -2406,19 +2406,10 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW)
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
fprintf(stderr,"%s: ht.%d\n", __func__, nHeight);
int32_t numhalvings,i; uint64_t numerator; CAmount nSubsidy = 3 * COIN;
if ( ASSETCHAINS_SYMBOL[0] == 0 )
{
if ( nHeight == 1 )
return(100000000 * COIN); // ICO allocation
else if ( nHeight < KOMODO_ENDOFERA )
return(3 * COIN);
else if ( nHeight < 2*KOMODO_ENDOFERA )
return(2 * COIN);
else return(COIN);
} else {
return(komodo_ac_block_subsidy(nHeight));
}
return komodo_ac_block_subsidy(nHeight);
}
bool IsInitialBlockDownload()

Loading…
Cancel
Save