Test
This commit is contained in:
@@ -672,21 +672,30 @@ uint64_t komodo_commission(const CBlock &block)
|
||||
|
||||
uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime)
|
||||
{
|
||||
CBlockIndex *pindex; arith_uint256 hashval; uint256 hash; int32_t i; uint32_t txtime,minutes,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN;
|
||||
CBlockIndex *pindex; arith_uint256 hashval; uint256 hash; int32_t i; uint32_t txtime,minutes,winner = 0; uint64_t diff,value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN;
|
||||
if ( nHeight < 200 )
|
||||
return(blocktime);
|
||||
txtime = komodo_txtime(&value,txid,vout);
|
||||
minutes = (blocktime - txtime) / 60;
|
||||
if ( txtime == 0 )
|
||||
txtime = prevtime;
|
||||
if ( (pindex= komodo_chainactive(nHeight-200)) != 0 )
|
||||
if ( blocktime > txtime && (pindex= komodo_chainactive(nHeight-200)) != 0 )
|
||||
{
|
||||
coinage = value * (blocktime - txtime) / supply;
|
||||
diff = (blocktime - txtime);
|
||||
coinage = value * diff / supply;
|
||||
hash = pindex->GetBlockHash(); // hash pubkey
|
||||
hashval = UintToArith256(hash);
|
||||
hashval = (hashval / arith_uint256(coinage+1));
|
||||
if ( hashval <= bnTarget )
|
||||
winner = 1;
|
||||
else
|
||||
{
|
||||
arith_uint256 val;
|
||||
val = bnTarget * arith_uint256(value*diff/supply) / UintToArith256(hash)
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&val)[i]);
|
||||
printf(" adjust val\n");
|
||||
}
|
||||
for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hashval)[i]);
|
||||
fprintf(stderr," vs ");
|
||||
|
||||
Reference in New Issue
Block a user