@@ -1664,7 +1664,9 @@ void *dealer0_loop(void *_arg)
|
|||||||
DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false);
|
DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false);
|
||||||
if ( entropytxs < DICE_MINUTXOS )
|
if ( entropytxs < DICE_MINUTXOS )
|
||||||
{
|
{
|
||||||
n = sqrt(DICE_MINUTXOS - entropytxs) + 10;
|
n = sqrt(DICE_MINUTXOS - entropytxs);
|
||||||
|
if ( n > 10 )
|
||||||
|
n = 10;
|
||||||
for (i=0; i<DICE_MINUTXOS - entropytxs && i<n; i++)
|
for (i=0; i<DICE_MINUTXOS - entropytxs && i<n; i++)
|
||||||
{
|
{
|
||||||
res = DiceAddfunding(txfee,planstr,dealer0_fundingtxid,1000*COIN);///100);
|
res = DiceAddfunding(txfee,planstr,dealer0_fundingtxid,1000*COIN);///100);
|
||||||
|
|||||||
@@ -1771,12 +1771,12 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
{
|
{
|
||||||
if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 )
|
if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 )
|
||||||
{
|
{
|
||||||
|
if ( slowflag == 0 ) // need all past 100 blocks to calculate PoW target
|
||||||
|
return(0);
|
||||||
if ( ASSETCHAINS_STAKED == 100 && height > 100 ) // only PoS allowed! POSTEST64
|
if ( ASSETCHAINS_STAKED == 100 && height > 100 ) // only PoS allowed! POSTEST64
|
||||||
return(-1);
|
return(-1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( slowflag == 0 ) // need all past 100 blocks to calculate PoW target
|
|
||||||
return(0);
|
|
||||||
if ( slowflag != 0 )
|
if ( slowflag != 0 )
|
||||||
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
||||||
if ( bhash > bnTarget )
|
if ( bhash > bnTarget )
|
||||||
@@ -1796,6 +1796,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
fprintf(stderr,"unexpected negative is_PoSblock.%d\n",is_PoSblock);
|
fprintf(stderr,"unexpected negative is_PoSblock.%d\n",is_PoSblock);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
else if ( ASSETCHAINS_STAKED != 0 )
|
||||||
|
failed = 0;
|
||||||
}
|
}
|
||||||
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -463,8 +463,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr;
|
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr;
|
||||||
CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight);
|
CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight);
|
||||||
|
|
||||||
//if ( blocktime > pindexPrev->GetMedianTimePast()+60 )
|
|
||||||
// blocktime = pindexPrev->GetMedianTimePast() + 60;
|
|
||||||
if (ASSETCHAINS_LWMAPOS != 0)
|
if (ASSETCHAINS_LWMAPOS != 0)
|
||||||
{
|
{
|
||||||
uint32_t nBitsPOS;
|
uint32_t nBitsPOS;
|
||||||
@@ -479,6 +477,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
blocktime = GetAdjustedTime();
|
||||||
|
//if ( blocktime > pindexPrev->GetMedianTimePast()+60 )
|
||||||
|
// blocktime = pindexPrev->GetMedianTimePast() + 60;
|
||||||
siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig);
|
siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5059,8 +5059,10 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk
|
|||||||
{
|
{
|
||||||
*maxkp += 1000;
|
*maxkp += 1000;
|
||||||
array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp));
|
array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp));
|
||||||
|
//fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array);
|
||||||
}
|
}
|
||||||
kp = &array[(*numkp)++];
|
kp = &array[(*numkp)++];
|
||||||
|
//fprintf(stderr,"kp.%p num.%d\n",kp,*numkp);
|
||||||
memset(kp,0,sizeof(*kp));
|
memset(kp,0,sizeof(*kp));
|
||||||
strcpy(kp->address,address);
|
strcpy(kp->address,address);
|
||||||
kp->txid = txid;
|
kp->txid = txid;
|
||||||
@@ -5083,15 +5085,11 @@ arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uin
|
|||||||
diff = 3600*24*30;
|
diff = 3600*24*30;
|
||||||
if ( iter > 0 )
|
if ( iter > 0 )
|
||||||
diff += segid*2;
|
diff += segid*2;
|
||||||
coinage = ((uint64_t)kp->nValue/COIN * diff);
|
coinage = ((uint64_t)kp->nValue * diff);
|
||||||
if ( blocktime+iter+segid*2 > prevtime+480 )
|
if ( blocktime+iter+segid*2 > prevtime+480 )
|
||||||
coinage *= ((blocktime+iter+segid*2) - (prevtime+400));
|
coinage *= ((blocktime+iter+segid*2) - (prevtime+400));
|
||||||
//if ( nHeight >= 2500 && blocktime+iter+segid*2 > prevtime+180 )
|
|
||||||
// coinage *= ((blocktime+iter+segid*2) - (prevtime+60));
|
|
||||||
coinage256 = arith_uint256(coinage+1);
|
coinage256 = arith_uint256(coinage+1);
|
||||||
hashval = ratio * (kp->hashval / coinage256);
|
hashval = ratio * (kp->hashval / coinage256);
|
||||||
//if ( nHeight >= 900 && nHeight < 916 )
|
|
||||||
// hashval = (hashval / coinage256);
|
|
||||||
return(hashval);
|
return(hashval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5121,7 +5119,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
|
|||||||
return(blocktime);
|
return(blocktime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else fprintf(stderr,"maxiters is not good enough\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5148,10 +5146,10 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
if ( (minage= nHeight*3) > 6000 ) // about 100 blocks
|
if ( (minage= nHeight*3) > 6000 ) // about 100 blocks
|
||||||
minage = 6000;
|
minage = 6000;
|
||||||
komodo_segids(hashbuf,nHeight-101,100);
|
komodo_segids(hashbuf,nHeight-101,100);
|
||||||
if ( *blocktimep > tipindex->nTime+60 )
|
if ( *blocktimep < tipindex->nTime+60 )
|
||||||
*blocktimep = tipindex->nTime+60;
|
*blocktimep = tipindex->nTime+60;
|
||||||
//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+600 )
|
if ( time(NULL) > lasttime+600 || array == 0 )
|
||||||
{
|
{
|
||||||
if ( array != 0 )
|
if ( array != 0 )
|
||||||
{
|
{
|
||||||
@@ -5170,7 +5168,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
counter++;
|
counter++;
|
||||||
if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth )
|
if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth);
|
fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||||
@@ -5184,12 +5182,14 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 )
|
if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 )
|
||||||
{
|
{
|
||||||
array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk);
|
array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk);
|
||||||
|
//fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep);
|
||||||
block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57;
|
block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57;
|
||||||
for (i=winners=0; i<numkp; i++)
|
for (i=winners=0; i<numkp; i++)
|
||||||
{
|
{
|
||||||
@@ -5238,7 +5238,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
|||||||
fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners);
|
fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners);
|
||||||
}
|
}
|
||||||
} //else fprintf(stderr,"utxo not eligible\n");
|
} //else fprintf(stderr,"utxo not eligible\n");
|
||||||
} //else fprintf(stderr,"no tipindex\n");
|
}
|
||||||
if ( numkp < 10000 && array != 0 )
|
if ( numkp < 10000 && array != 0 )
|
||||||
{
|
{
|
||||||
free(array);
|
free(array);
|
||||||
|
|||||||
Reference in New Issue
Block a user