Test
This commit is contained in:
@@ -4660,7 +4660,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
|
|||||||
hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime);
|
hashval = _komodo_eligible(kp,ratio,blocktime,iter,minage,segid,nHeight,prevtime);
|
||||||
if ( hashval <= bnTarget )
|
if ( hashval <= bnTarget )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"winner blocktime.%u iter.%d segid.%d\n",blocktime,iter,segid);
|
fprintf(stderr,"winner %.8f blocktime.%u iter.%d segid.%d\n",(double)kp->nValue/COIN,blocktime,iter,segid);
|
||||||
blocktime += iter;
|
blocktime += iter;
|
||||||
blocktime += segid * 2;
|
blocktime += segid * 2;
|
||||||
return(blocktime);
|
return(blocktime);
|
||||||
@@ -4673,12 +4673,12 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
|
|||||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig)
|
||||||
{
|
{
|
||||||
static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime;
|
static struct komodo_staking *array; static int32_t numkp,maxkp; static uint32_t lasttime;
|
||||||
set<CBitcoinAddress> setAddress; struct komodo_staking *kp; int32_t segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector<COutput> vecOutputs; uint32_t besttime,eligible,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock;
|
set<CBitcoinAddress> setAddress; struct komodo_staking *kp; int32_t segid,minage,nHeight,counter=0,i,m,siglen=0,nMinDepth = 1,nMaxDepth = 99999999; vector<COutput> vecOutputs; uint32_t besttime,eligible,eligible2,earliest = 0; CScript best_scriptPubKey; arith_uint256 mindiff,ratio,bnTarget; CBlockIndex *tipindex,*pindex; CTxDestination address; bool fNegative,fOverflow; uint8_t hashbuf[256]; CTransaction tx; uint256 hashBlock;
|
||||||
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
|
||||||
mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
mindiff.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||||
ratio = (mindiff / bnTarget);
|
ratio = (mindiff / bnTarget);
|
||||||
assert(pwalletMain != NULL);
|
assert(pwalletMain != NULL);
|
||||||
//LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
*utxovaluep = 0;
|
*utxovaluep = 0;
|
||||||
memset(utxotxidp,0,sizeof(*utxotxidp));
|
memset(utxotxidp,0,sizeof(*utxotxidp));
|
||||||
memset(utxovoutp,0,sizeof(*utxovoutp));
|
memset(utxovoutp,0,sizeof(*utxovoutp));
|
||||||
@@ -4691,7 +4691,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
minage = 6000;
|
minage = 6000;
|
||||||
komodo_segids(hashbuf,nHeight-101,100);
|
komodo_segids(hashbuf,nHeight-101,100);
|
||||||
fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight);
|
fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight);
|
||||||
//if ( time(NULL) > lasttime+60 )
|
if ( time(NULL) > lasttime+60 )
|
||||||
{
|
{
|
||||||
if ( array != 0 )
|
if ( array != 0 )
|
||||||
{
|
{
|
||||||
@@ -4730,7 +4730,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
lasttime = (uint32_t)time(NULL);
|
lasttime = (uint32_t)time(NULL);
|
||||||
fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp);
|
fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp);
|
||||||
}
|
}
|
||||||
for (i=0; i<numkp; i++)
|
for (i=0; i<numkp&&i<100; i++)
|
||||||
{
|
{
|
||||||
if ( (tipindex= chainActive.Tip()) == 0 || tipindex->nHeight+1 > nHeight )
|
if ( (tipindex= chainActive.Tip()) == 0 || tipindex->nHeight+1 > nHeight )
|
||||||
{
|
{
|
||||||
@@ -4738,9 +4738,10 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
kp = &array[i];
|
kp = &array[i];
|
||||||
if ( (eligible= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage)) == 0 )
|
if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage)) == 0 )
|
||||||
continue;
|
continue;
|
||||||
eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address);
|
eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address);
|
||||||
|
fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible);
|
||||||
if ( eligible > 0 )
|
if ( eligible > 0 )
|
||||||
{
|
{
|
||||||
besttime = m = 0;
|
besttime = m = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user