From 8373141bb7b8fdaadbfd125358d89d986024ff3e Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Apr 2018 04:43:43 +0300 Subject: [PATCH 1/5] Test --- src/komodo_gateway.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4a92b6e5a..026969dac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -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); - hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); + diff = (blocktime - txtime - minage); + //if ( diff > 3600 ) + // diff = 3600; + //coinage = (((value * diff) / supply) * diff); + coinage = (value * diff); + //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 ) + // break; coinage = (((value * diff) / supply) * diff); hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); if ( hashval <= bnTarget ) From 188e19a735d6e7c42a1f97a86dfbe73ae5f3ed44 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Apr 2018 04:45:45 +0300 Subject: [PATCH 2/5] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 026969dac..d89936c37 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -693,7 +693,7 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_ //if ( diff > 3600 ) // diff = 3600; //coinage = (((value * diff) / supply) * diff); - coinage = (value * 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 ) @@ -720,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]); From c09e3fa1a7873504b2bcc561733e41fcc30b7115 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Apr 2018 04:48:32 +0300 Subject: [PATCH 3/5] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d89936c37..778be3eca 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -690,8 +690,8 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_ 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 - minage); - //if ( diff > 3600 ) - // diff = 3600; + 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)); @@ -706,8 +706,8 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_ for (iter=1; iter<3600; iter++) { diff = (iter + blocktime - txtime - minage); - //if ( diff > 3600 ) - // break; + if ( diff > 3600*24 ) + break; coinage = (((value * diff) / supply) * diff); hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); if ( hashval <= bnTarget ) From 52955b6feca259312188859a43860703564c3299 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Apr 2018 04:53:05 +0300 Subject: [PATCH 4/5] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 778be3eca..d29e70261 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -694,8 +694,8 @@ uint32_t komodo_stake(arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_ 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)); + hashval = arith_uint256(supply * 64) * (UintToArith256(hash) / arith_uint256(coinage+1)); + //hashval = (UintToArith256(hash) / arith_uint256(coinage+1)); if ( hashval <= bnTarget ) { winner = 1; From f21f0d70412eb8b072342534f9af2833a4c938b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 11 Apr 2018 04:59:39 +0300 Subject: [PATCH 5/5] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 692db8ce6..b5187a615 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -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 )