Sprout funds

This commit is contained in:
jl777
2018-12-15 15:03:24 -11:00
parent 77528e4ebb
commit 3491227494
2 changed files with 7 additions and 5 deletions

View File

@@ -219,7 +219,7 @@ public:
CBlockIndex* pskip; CBlockIndex* pskip;
//! height of the entry in the chain. The genesis block has height 0 //! height of the entry in the chain. The genesis block has height 0
int64_t newcoins,zfunds; int8_t segid; // jl777 fields int64_t newcoins,zfunds,sproutfunds; int8_t segid; // jl777 fields
//! Which # file this block is stored in (blk?????.dat) //! Which # file this block is stored in (blk?????.dat)
int nFile; int nFile;

View File

@@ -1907,11 +1907,11 @@ int64_t komodo_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,C
return(voutsum - vinsum); return(voutsum - vinsum);
} }
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height) int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height)
{ {
CBlockIndex *pindex; CBlock block; int64_t zfunds=0,supply = 0; CBlockIndex *pindex; CBlock block; int64_t zfunds=0,sproutfunds=0,supply = 0;
//fprintf(stderr,"coinsupply %d\n",height); //fprintf(stderr,"coinsupply %d\n",height);
*zfundsp = 0; *zfundsp = *sproutfundsp = 0;
if ( (pindex= komodo_chainactive(height)) != 0 ) if ( (pindex= komodo_chainactive(height)) != 0 )
{ {
while ( pindex != 0 && pindex->GetHeight() > 0 ) while ( pindex != 0 && pindex->GetHeight() > 0 )
@@ -1919,7 +1919,7 @@ int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height)
if ( pindex->newcoins == 0 && pindex->zfunds == 0 ) if ( pindex->newcoins == 0 && pindex->zfunds == 0 )
{ {
if ( komodo_blockload(block,pindex) == 0 ) if ( komodo_blockload(block,pindex) == 0 )
pindex->newcoins = komodo_newcoins(&pindex->zfunds,pindex->GetHeight(),&block); pindex->newcoins = komodo_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block);
else else
{ {
fprintf(stderr,"error loading block.%d\n",pindex->GetHeight()); fprintf(stderr,"error loading block.%d\n",pindex->GetHeight());
@@ -1928,10 +1928,12 @@ int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height)
} }
supply += pindex->newcoins; supply += pindex->newcoins;
zfunds += pindex->zfunds; zfunds += pindex->zfunds;
sproutfunds += pindex->sproutfunds;
//printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds)); //printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds));
pindex = pindex->pprev; pindex = pindex->pprev;
} }
} }
*zfundsp = zfunds; *zfundsp = zfunds;
*sproutfundsp = sproutfunds;
return(supply); return(supply);
} }