This commit is contained in:
jl777
2019-03-01 01:47:09 -11:00
parent 50acda6640
commit 1f8591b0e9
4 changed files with 33 additions and 9 deletions

View File

@@ -129,7 +129,7 @@ int32_t komodo_baseid(char *origbase)
#ifndef SATOSHIDEN
#define SATOSHIDEN ((uint64_t)100000000L)
#endif
int64_t komodo_current_supply(uint32_t nHeight)
uint64_t komodo_current_supply(uint32_t nHeight)
{
uint64_t cur_money;
int32_t baseid;
@@ -264,5 +264,19 @@ int64_t komodo_current_supply(uint32_t nHeight)
}
}
}
return((int64_t)(cur_money + (cur_money * ASSETCHAINS_COMMISSION)));
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
if ( KOMODO_BIT63SET(cur_money) != 0 )
return(KOMODO_MAXNVALUE);
if ( ASSETCHAINS_COMMISSION != 0 )
{
uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION));
if ( KOMODO_BIT63SET(newval) != 0 )
return(KOMODO_MAXNVALUE);
else if ( newval < curval ) // check for underflow
return(KOMODO_MAXNVALUE);
return(newvalue)
}
return(cur_money);
}