Merge pull request #561 from jl777/jl777

tweak PoS
This commit is contained in:
jl777
2018-04-11 05:11:28 +03:00
committed by GitHub
2 changed files with 12 additions and 6 deletions

View File

@@ -689,9 +689,13 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_
memcpy(&hashbuf[sizeof(pasthash)],&addrhash,sizeof(addrhash));
vcalc_sha256(0,(uint8_t *)&hash,hashbuf,(int32_t)sizeof(uint256)*2);
//fprintf(stderr,"(%s) vs. (%s) %s %.8f txtime.%u\n",address,destaddr,hash.ToString().c_str(),dstr(value),txtime);
diff = (blocktime - txtime);
coinage = (((value * diff) / supply) * diff);
diff = (blocktime - txtime - minage);
if ( diff > 3600*24 )
diff = 3600*24;
//coinage = (((value * diff) / supply) * diff);
coinage = (value * diff) * ((diff >> 16) + 1);
hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1));
//hashval = (UintToArith256(hash) / arith_uint256(coinage+1));
if ( hashval <= bnTarget )
{
winner = 1;
@@ -699,9 +703,11 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_
}
else
{
for (iter=1; iter<3600*8; iter++)
for (iter=1; iter<3600; iter++)
{
diff = (iter + blocktime - txtime);
diff = (iter + blocktime - txtime - minage);
if ( diff > 3600*24 )
break;
coinage = (((value * diff) / supply) * diff);
hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1));
if ( hashval <= bnTarget )
@@ -714,7 +720,7 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_
}
//fprintf(stderr,"iterated until i.%d winner.%d\n",i,winner);
}
if ( 0 )
if ( 1 )
{
for (i=31; i>=24; i--)
fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]);

View File

@@ -385,7 +385,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
blocktime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
pblock->nTime = blocktime;
pblock->nTime = blocktime + 1;
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
//LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && NOTARY_PUBKEY33[0] != 0 )