From 6eb0958c4d03eae1f2705f667d9cf947f7a5c4af Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 9 Apr 2018 19:57:32 +0300 Subject: [PATCH] Test --- src/komodo_gateway.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e52c27ac4..4e0257fff 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -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 ");