From 76bb0a23608502b341b0a3d795486a541e5d1cb0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:41:09 -1100 Subject: [PATCH 1/7] +print --- src/komodo_globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 44c12bdf4..0abe48ace 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -264,6 +264,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) } } } + fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) From 1d692f4df361c88bce7527fd22dc643f128dc6c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:45:06 -1100 Subject: [PATCH 2/7] Fix maxmoney estimate for acPErc --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0abe48ace..0eaa430a3 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -269,7 +269,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) { - uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)); + uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)/COIN); if ( KOMODO_BIT63SET(newval) != 0 ) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow From ef8df0fd1bab6d0c61f9470acce3b62c4c9cba99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:49:37 -1100 Subject: [PATCH 3/7] +print --- src/komodo_globals.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0eaa430a3..096b31a37 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -169,7 +169,9 @@ uint64_t komodo_current_supply(uint32_t nHeight) if (!period) { // no halving, straight multiply + fprintf(stderr,"cur_money %.8f += %.8f * %d\n",(double)cur_money/COIN,(double)reward/COIN,nHeight); cur_money += reward * (nHeight - 1); + fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } // if exactly SATOSHIDEN, linear decay to zero or to next era, same as: // (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks @@ -264,12 +266,11 @@ uint64_t komodo_current_supply(uint32_t nHeight) } } } - fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); if ( KOMODO_BIT63SET(cur_money) != 0 ) return(KOMODO_MAXNVALUE); if ( ASSETCHAINS_COMMISSION != 0 ) { - uint64_t newval = (cur_money + (cur_money * ASSETCHAINS_COMMISSION)/COIN); + uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION)); if ( KOMODO_BIT63SET(newval) != 0 ) return(KOMODO_MAXNVALUE); else if ( newval < cur_money ) // check for underflow From 022cfeee63839ca1dded623ff626ed1316373f2d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:54:50 -1100 Subject: [PATCH 4/7] +print --- src/komodo_globals.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 096b31a37..72f0ebbb7 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -134,9 +134,9 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint64_t cur_money; int32_t baseid; - if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) - cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; - else + //if ( (baseid = komodo_baseid(ASSETCHAINS_SYMBOL)) >= 0 && baseid < 32 ) + // cur_money = ASSETCHAINS_GENESISTXVAL + ASSETCHAINS_SUPPLY + nHeight * ASSETCHAINS_REWARD[0] / SATOSHIDEN; + //else { // figure out max_money by adding up supply to a maximum of 10,000,000 blocks cur_money = (ASSETCHAINS_SUPPLY+1) * SATOSHIDEN + (ASSETCHAINS_MAGIC & 0xffffff) + ASSETCHAINS_GENESISTXVAL; @@ -155,6 +155,8 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; + + fprintf(stderr,"last.%d reward %llu period %llu\n",ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; From 25109df8ec4ce187e38a06c67f2927bcfd1c75d4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 07:57:19 -1100 Subject: [PATCH 5/7] Test --- src/komodo_globals.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 72f0ebbb7..13ec6eb80 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -156,7 +156,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; - fprintf(stderr,"last.%d reward %llu period %llu\n",ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); + fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; @@ -168,10 +168,10 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; + fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); if (!period) { // no halving, straight multiply - fprintf(stderr,"cur_money %.8f += %.8f * %d\n",(double)cur_money/COIN,(double)reward/COIN,nHeight); cur_money += reward * (nHeight - 1); fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } From 9b9f61566d9198c9ebc25eb2ab916a84f8cecab1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 08:00:58 -1100 Subject: [PATCH 6/7] Fix maxmoney calc for period 0 chains --- src/komodo_globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 13ec6eb80..0cc5ab6f8 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -169,7 +169,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint64_t decay = ASSETCHAINS_DECAY[j]; fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); - if (!period) + if ( ASSETCHAINS_HALVING[j] == 0 ) { // no halving, straight multiply cur_money += reward * (nHeight - 1); From 729edc4e80bb7095dfc72300f565c3c5f196eb34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 2 Mar 2019 08:03:10 -1100 Subject: [PATCH 7/7] -print --- src/komodo_globals.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 0cc5ab6f8..69ad6b840 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -156,7 +156,7 @@ uint64_t komodo_current_supply(uint32_t nHeight) // add rewards from this era, up to nHeight int64_t reward = ASSETCHAINS_REWARD[j]; - fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); + //fprintf(stderr,"last.%d reward %llu period %llu\n",(int32_t)ASSETCHAINS_LASTERA,(long long)reward,(long long)ASSETCHAINS_HALVING[j]); if ( reward > 0 ) { uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; @@ -168,12 +168,12 @@ uint64_t komodo_current_supply(uint32_t nHeight) uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; - fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); + //fprintf(stderr,"period.%llu cur_money %.8f += %.8f * %d\n",(long long)period,(double)cur_money/COIN,(double)reward/COIN,nHeight); if ( ASSETCHAINS_HALVING[j] == 0 ) { // no halving, straight multiply cur_money += reward * (nHeight - 1); - fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); + //fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); } // if exactly SATOSHIDEN, linear decay to zero or to next era, same as: // (next_era_reward + (starting reward - next_era_reward) / 2) * num_blocks @@ -279,6 +279,6 @@ uint64_t komodo_current_supply(uint32_t nHeight) return(KOMODO_MAXNVALUE); return(newval); } - fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); + //fprintf(stderr,"cur_money %.8f\n",(double)cur_money/COIN); return(cur_money); }