VerusHash fix. 100% PoW wasnt working, min diff is now much higher fixing PoW doing 1s blocks.
This commit is contained in:
@@ -1296,6 +1296,11 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh
|
||||
if ( iter > 0 )
|
||||
diff += segid*2;
|
||||
coinage = (value * diff);
|
||||
if ( ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH )
|
||||
{
|
||||
if ( blocktime+iter+segid*2 > prevtime+200 )
|
||||
coinage *= ((blocktime+iter+segid*2) - (prevtime+120));
|
||||
}
|
||||
if ( blocktime+iter+segid*2 > prevtime+480 )
|
||||
coinage *= ((blocktime+iter+segid*2) - (prevtime+400));
|
||||
coinage256 = arith_uint256(coinage+1);
|
||||
@@ -1339,14 +1344,9 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh
|
||||
|
||||
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc)
|
||||
{
|
||||
int32_t oldflag = 0,dispflag = 0;
|
||||
int32_t oldflag = 0,dispflag = 1;
|
||||
CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val;
|
||||
*percPoSp = percPoS = 0;
|
||||
static bool new_rules, didinit;
|
||||
if ( !didinit ) {
|
||||
new_rules = is_STAKED(ASSETCHAINS_SYMBOL) != 0 && is_STAKED(ASSETCHAINS_SYMBOL) != 3 ? true : false;
|
||||
didinit = true;
|
||||
}
|
||||
|
||||
if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) )
|
||||
return(target);
|
||||
@@ -1359,9 +1359,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
|
||||
ht = height - 100 + i;
|
||||
if ( ht <= 1 )
|
||||
continue;
|
||||
// never count the first 10 blocks, they are always PoW! Cant do this for old chains, so limit to LABS and LAB for now.
|
||||
if ( new_rules && ht < 10 )
|
||||
continue;
|
||||
if ( (pindex= komodo_chainactive(ht)) != 0 )
|
||||
{
|
||||
if ( komodo_segid(0,ht) >= 0 )
|
||||
@@ -1385,12 +1382,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
|
||||
// We now do actual PoS % at the start. Requires coin distribution in first 10 blocks!
|
||||
// This is not hard to do and stops the chain having its PoS/PoW in large chunks.
|
||||
if ( m+n < 100 )
|
||||
{
|
||||
if ( new_rules)
|
||||
percPoS = (percPoS*100) / (m+n);
|
||||
else
|
||||
percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100;
|
||||
}
|
||||
percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100;
|
||||
if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 )
|
||||
fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height);
|
||||
*percPoSp = percPoS;
|
||||
@@ -1449,7 +1441,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
|
||||
fprintf(stderr," ht.%d percPoS.%d vs goal.%d -> diff %d\n",height,percPoS,goalperc,goalperc - percPoS);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
bnTarget = ave; // recent ave is perfect
|
||||
return(bnTarget);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ uint32_t ASSETCHAINS_NONCESHIFT[] = {32,16};
|
||||
uint32_t ASSETCHAINS_HASHESPERROUND[] = {1,4096};
|
||||
uint32_t ASSETCHAINS_ALGO = _ASSETCHAINS_EQUIHASH;
|
||||
// min diff returned from GetNextWorkRequired needs to be added here for each algo, so they can work with ac_staked.
|
||||
uint32_t ASSETCHAINS_MINDIFF[] = {537857807,504303375};
|
||||
uint32_t ASSETCHAINS_MINDIFF[] = {537857807,486648905};
|
||||
// nBits.486704888 -- too low?
|
||||
|
||||
|
||||
// Verus proof of stake controls
|
||||
int32_t ASSETCHAINS_LWMAPOS = 0; // percentage of blocks should be PoS
|
||||
|
||||
@@ -1297,6 +1297,7 @@ void static BitcoinMiner_noeq()
|
||||
pblock->nSolution = solnPlaceholder;
|
||||
savebits = pblock->nBits;
|
||||
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||
HASHTarget = arith_uint256().SetCompact(savebits);
|
||||
arith_uint256 mask(ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO]);
|
||||
|
||||
Mining_start = 0;
|
||||
@@ -1315,8 +1316,8 @@ void static BitcoinMiner_noeq()
|
||||
if ( ASSETCHAINS_STAKED != 0 )
|
||||
{
|
||||
int32_t percPoS,z; bool fNegative,fOverflow;
|
||||
HASHTarget_POW = komodo_PoWtarget(&percPoS,hashTarget,Mining_height,ASSETCHAINS_STAKED);
|
||||
HASHTarget.SetCompact(STAKING_MIN_DIFF,&fNegative,&fOverflow);
|
||||
HASHTarget_POW = komodo_PoWtarget(&percPoS,HASHTarget,Mining_height,ASSETCHAINS_STAKED);
|
||||
HASHTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
LogPrintf("Block %d : PoS %d%% vs target %d%%\n", Mining_height, percPoS, (int32_t)ASSETCHAINS_STAKED);
|
||||
}
|
||||
|
||||
@@ -1332,10 +1333,12 @@ void static BitcoinMiner_noeq()
|
||||
vh.ClearExtra();
|
||||
int64_t i, count = ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1;
|
||||
int64_t hashesToGo = ASSETCHAINS_HASHESPERROUND[ASSETCHAINS_ALGO];
|
||||
if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 )
|
||||
hashTarget = HASHTarget_POW;
|
||||
else hashTarget = HASHTarget;
|
||||
|
||||
if ( ASSETCHAINS_STAKED != 0)
|
||||
{
|
||||
if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED < 100 )
|
||||
hashTarget = HASHTarget_POW;
|
||||
else hashTarget = HASHTarget;
|
||||
}
|
||||
// for speed check NONCEMASK at a time
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
@@ -1429,6 +1432,7 @@ void static BitcoinMiner_noeq()
|
||||
#else
|
||||
printf("%lu mega hashes complete - working\n", (ASSETCHAINS_NONCEMASK[ASSETCHAINS_ALGO] + 1) / 1048576);
|
||||
#endif
|
||||
pblock->nBits = savebits;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ int8_t is_STAKED(const char *chain_name) {
|
||||
static int8_t STAKED,doneinit;
|
||||
if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0)
|
||||
return(STAKED);
|
||||
if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) )
|
||||
if ( (strcmp(chain_name, "LABMAIN") == 0) || (strncmp(chain_name, "LABT1", 4) == 0) )
|
||||
STAKED = 1;
|
||||
else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) )
|
||||
else if ( (strcmp(chain_name, "LABT2") == 0) || (strncmp(chain_name, "LABT2", 3) == 0) )
|
||||
STAKED = 2;
|
||||
else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) )
|
||||
STAKED = 3;
|
||||
|
||||
Reference in New Issue
Block a user